platformio / platform-atmelsam

Atmel SAM: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/atmelsam
Apache License 2.0
79 stars 105 forks source link

The code is not correctly offset in flash for a Zephyr setup (at least on Adafruit Feather M0) #91

Open KubaFYI opened 4 years ago

KubaFYI commented 4 years ago

I was trying to get the Zephyr blinky example work on an Adafruit Feather M0 and noticed it doesn't work straight out of the box.

I've been able to narrow the source of the problem down to the linker scripts generating a linker command file which doesn't offsetting the program memory by correctly (it's assumed to start at 0x0 while the Feather's bootloader needs it to start at 0x2000). Changing line 4 of linker_pass_final.cmd from FLASH (rx) : ORIGIN = (0x0 + 0x0), LENGTH = (256*1K - 0x0) to FLASH (rx) : ORIGIN = (0x2000 + 0x0), LENGTH = (256*1K - 0x2000) and building fixes it. This should probably be a default configuration.

I've tried making it so but it seems I'm not familiar enough with Zephyr or the way it integrates into PlatformIO to figure out where things go wrong. The adafruit_feather_m0_basic_proto device tree correctly describes the flash code partition as living at the address 0x2000. Maybe that's not sufficient?

KubaFYI commented 4 years ago

This seems to be related to a more general problem with zephyr not flashing Adafruit Feather M0's out of the box. See zephyrproject-rtos/zephyr#22062.

liquiddandruff commented 3 years ago

This is resolved now right? Will be getting a Feather M0 RFM95 soon and would like it very much if I can flash :).

I'll report back if https://github.com/zephyrproject-rtos/zephyr/pull/22180 fixes this issue and if so then this can be closed.