Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include bare bone spm routine #351

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

include bare bone spm routine #351

wants to merge 1 commit into from

Conversation

agsb
Copy link

@agsb agsb commented Jul 21, 2022

This include a minimal bare bones spm routine, for non arduino and assembler gcc programs.
Uses r0:r1, r30:r31, as default, and r24:r25 as command and sreg holder.
Only does spm, wait and return. Only. Could be selected instead do_spm.

@WestfW
Copy link
Member

WestfW commented Jul 21, 2022

Why?
Effectively, it can only be used from ASM, due to register use.
It's not significantly shorter than the existing code, except for the missing re-enable of RWWSRE, which is pretty important.

@agsb
Copy link
Author

agsb commented Jul 22, 2022

Exact, as just an alternative of do_spm for use in ASM, and left to user do the tricks.

@agsb
Copy link
Author

agsb commented Oct 17, 2022

Thanks ! Your modification for _boot_rww_enable_short() solves my request in a much wise form.

// Reenable read access to flash
__boot_rww_enable_short();
7fd2:	87 bf       	out	0x37, r24	; 55
7fd4:	e8 95       	spm
7fd6:	08 95       	ret

@mcuee
Copy link

mcuee commented Dec 20, 2022

In this case, this PR can be closed.

https://github.com/Optiboot/optiboot/blob/master/optiboot/bootloaders/optiboot/boot_opt.h#L72-L82

#define __boot_rww_enable_short()                \
(__extension__({                                 \
    __asm__ __volatile__                         \
    (                                            \
        "__wr_spmcsr %0, %1\n\t"                 \
        "spm\n\t"                                \
        :                                        \
        : "i" (_SFR_MEM_ADDR(__SPM_REG)),         \
          "r" ((uint8_t)__BOOT_RWW_ENABLE)       \
    );                                           \
}))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants