Samd21 build help - NVIC_SystemReset();

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
nohc
Posts: 9
Joined: Sat Aug 22, 2020 12:16 am

Samd21 build help - NVIC_SystemReset();

Post by nohc » Thu Sep 17, 2020 2:38 am

Hello, I am trying to do an Arduino Zero compatible build and I am using the board config files from CircuitPython's build. There are some hangups in modmachine.c that I have gotten past. I could not find the sam.h file that is imported and I have not found an example so I created an empty sam.h file and just manually added in the missing definitions that were flagged, like CPU_FREQ. There seems to be a function that I don't know where it gets defined though. Details below. Thanks

modmachine.c: In function 'machine_reset':
modmachine.c:44:5: error: implicit declaration of function 'NVIC_SystemReset' [-Werror=implicit-function-declaration]
44 | NVIC_SystemReset();


NVIC_SystemReset();

Board config I am using
https://github.com/adafruit/circuitpyth ... duino_zero

File that references the function
https://github.com/micropython/micropyt ... dmachine.c

STATIC mp_obj_t machine_reset(void) {
*DBL_TAP_ADDR = DBL_TAP_MAGIC_RESET;
NVIC_SystemReset();
return mp_const_none;

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Samd21 build help - NVIC_SystemReset();

Post by jimmo » Tue Oct 20, 2020 12:59 pm

nohc wrote:
Thu Sep 17, 2020 2:38 am
There seems to be a function that I don't know where it gets defined though.
NVIC_SystemReset comes from CMSIS.

Can you provide more information about what you're doing? I'm a bit confused by the fact that you're mixing CircuitPython and MicroPython (which are very different when it comes to this stuff).

nohc
Posts: 9
Joined: Sat Aug 22, 2020 12:16 am

Re: Samd21 build help - NVIC_SystemReset();

Post by nohc » Thu Oct 29, 2020 2:58 am

My ultimate goal here was to get a working firmware on a samd21 board that supports sleep mode and interrupts. I was under the impression that the samd MP ports do not work without additional information and somehow in my though process I figured I could borrow the CircuitPython files as a starting place for an Arduino Zero build. I am probably way off on that and since then have taken many steps back. I guess a much better starting place on this would be to know: Do the ports for the samd builds currently work on their respective boards as is and do they support sleep and interrupts? I would just try it but I don't have any of those boards to test with.

A little more background, I am trying to create some low power boards to run on battery for an extended period of time and use RFM69 modules to communicate sensor data. I have some Moteino M0s which are essentially an Arduino Zero with low power friendly components and the radio module build in. I wanted to try and get MP running on those boards and then eventually design my own boards with the needed sensors built in.

I have since then discovered Peter's work on lowpower MP applications with the pyboard and that is very promising. I ordered one of each type of pyboard and my project has been moving along well since. The benefit of working with the well documented official build has made life so much easier. I am still interested in the samd build and as I learn more want to revisit it.

Thanks

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Samd21 build help - NVIC_SystemReset();

Post by jimmo » Thu Oct 29, 2020 4:35 am

nohc wrote:
Thu Oct 29, 2020 2:58 am
My ultimate goal here was to get a working firmware on a samd21 board that supports sleep mode and interrupts. I was under the impression that the samd MP ports do not work without additional information and somehow in my though process I figured I could borrow the CircuitPython files as a starting place for an Arduino Zero build. I am probably way off on that and since then have taken many steps back. I guess a much better starting place on this would be to know: Do the ports for the samd builds currently work on their respective boards as is and do they support sleep and interrupts? I would just try it but I don't have any of those boards to test with.
The current SAMD port is very minimal, but it's a good starting point. Definitely easier than starting from scratch. It looks like your M0 boards are very similar to the two M0 boads that we do have support for (the M0 Express, which is a SAMD21G18A, and the Trinket M0, which is a SAMD21E18A). Either way, any SAMD21 chip should be easy to support -- just copy boards/X and modify mpconfigboard.h and mpconfigboard.mk respectively.

But yeah, we don't have low power mode or sleep modes supported yet, however interrupts are somewhat supported (i.e the UART RX IRQ). The main issue on this port is very little work has been done on the hardware APIs (i.e. the machine module). machine.Pin would be a good start.

Post Reply