Hello all,
So my current situation is this:
I would like to develop and debug my main application on my device with a bootloader on it. I cannot program the main app to flash if I haven't erased the entire chip first.
I am using a STM32L475VExx microcontroller and I am utilizing its 512kB of flash for a bootloader and main application.
The memory map is as follows:
Address Space -> Contents 0x08000000 - 0x08020000 -> Bootloader Space 0x0801FFF8 - 0x0801FFFC -> Bootloader Attributes 0x08040000 – 0x08040002 -> Configuration information 0x08040003 – 0x08040003 + Length of App -> Application space 0x0805FFFC - 0x0805FFF8 -> Attributes of application
I wanted to separate the banks of flash for the app and the bootloader. Bank 1 is from 0x08000000 - 0x0803FFFF while bank 2 is from 0x08040000 - 0x0807FFFF. Each have 256kB.
I have a USB peripheral programming everything just fine and it erases the 2nd bank of flash before programming, which I can visually see in the debugging memory window.
However, if I try to use the J-Link Segger Ultra+, then programming fails.
Here is the mysterious part, when the bootloader is on the device, and the app is as well, I try to program just the app and it fails, but if I change the Flash Tool settings for programming the bootloader in Keil to erase the full chip, program the bootloader, then try to program the app directly after from an erased state, it programs just fine!
I have the Flash Tool settings in Keil for the STM32L4xx 1MB (Not sure if this makes a difference, since it is a 512kB variant), with the address range from 0x08040000 - 0x0805FFFF. It also has the "Erase Sectors" setting checked.
After a bit of investigation, I am suspecting that a "Sector" from Keil is not the same as what the chip is expecting and the Segger isn't erasing some of the application data, causing a flash write to fail. However, I have not been able to understand this enough and I was wondering if anyone else has had a similar problem, or direction they could point me in to figuring this out.
Here is the Segger output:
* JLink Info: Device "STM32L475VG" selected.
JLink info: ------------ DLL: V6.16c, compiled Jun 16 2017 18:14:49 Firmware: J-Link Ultra V4 compiled Mar 2 2018 17:08:39 Hardware: V4.00 S/N : 504302210 Feature(s) : RDI, FlashBP, FlashDL, JFlash, GDB
* JLink Info: Found SW-DP with ID 0x2BA01477 * JLink Info: Found SW-DP with ID 0x2BA01477 * JLink Info: Scanning APs, stopping at first AHB-AP found. * JLink Info: AP[0] IDR: 0x24770011 (AHB-AP) * JLink Info: AHB-AP ROM: 0xE00FF000 (Base addr. of first ROM table) * JLink Info: CPUID reg: 0x410FC241. Implementer code: 0x41 (ARM) * JLink Info: Found Cortex-M4 r0p1, Little endian. * JLink Info: FPUnit: 6 code (BP) slots and 2 literal slots * JLink Info: CoreSight components: * JLink Info: ROMTbl[0] @ E00FF000 * JLink Info: ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS * JLink Info: ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT * JLink Info: ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB * JLink Info: ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM * JLink Info: ROMTbl[0][4]: E0040000, CID: B105900D, PID: 000BB9A1 TPIU * JLink Info: ROMTbl[0][5]: E0041000, CID: B105900D, PID: 000BB925 ETM ROMTableAddr = 0xE00FF000 * JLink Info: Setting AIRCR.SYSRESETREQ
Target info: ------------ Device: STM32L475VGTx VTarget = 3.295V State of Pins: TCK: 0, TDI: 0, TDO: 0, TMS: 1, TRES: 1, TRST: 1 Hardware-Breakpoints: 6 Software-Breakpoints: 8192 Watchpoints: 4 JTAG speed: 50000 kHz
Include "C:\\JustaPathtomyDEBUGINI" LOAD .\Objects\SCA.hex // load the application Erase Done. Programming Failed! Error: Flash Download failed - "Cortex-M4" Flash Load finished at 15:09:26
Any help would be appreciated.
Thank you!