0
votes

I have been trying to get my grips around programming STM32. I have got a Nornir developed Dash7/sensor board (for which absolutely no documentation exists somehow...), which has a STM32L100RBT6 MCU. So I'd like to program my own software for this board.

So far I have succesfully made a project and build the firmware. At this point I am trying to flash the .hex file onto the MCU using a official ST-link v2 programmer, in combination with the ST-Link utility software (under windows 10). I am using the JTAG interface on the board.

In the ST-link utility, I can connect to the board, and read it out. I have erased the chip, and I only read zeros in the memory, for both memory pages (0x00000000 and 0x08000000).

When I try Target > Program it however, after selecting my .hex file and hitting Start, the console tells me:

16:54:48 : Connected via JTAG.
16:54:48 : Connection mode : Normal.
16:54:48 : Debug in Low Power mode enabled.
16:54:49 : Device ID:0x416 
16:54:49 : Device flash Size : 128KBytes
16:54:49 : Device family :STM32L100x8/L15xx8
16:54:52 : Memory programmed in 0s and 250ms.

But when I read out the memory, it is not programmed. It only shows me zeros on both pages (0x00000000 and 0x08000000).

When I select Target > Program & Verify, I get a error message 'programming error @: 0x00000001' and the following console output:

16:55:39 : Connected via JTAG.
16:55:39 : Connection mode : Normal.
16:55:39 : Debug in Low Power mode enabled.
16:55:39 : Device ID:0x416 
16:55:39 : Device flash Size : 128KBytes
16:55:39 : Device family :STM32L100x8/L15xx8
16:56:16 : No OnChip verification function found. Verify after programming will be performed.
16:56:17 : Programming error @: 0x00000001

My memory linker script (mem.ld) is as follows:

MEMORY
{
  FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K
  RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 10K

  /*
   * Optional sections; define the origin and length to match
   * the the specific requirements of your hardware. The zero
   * length prevents inadvertent allocation.
   */
  CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 0
  FLASHB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0
  EXTMEMB0 (rx) : ORIGIN = 0x00000000, LENGTH = 0
  EXTMEMB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0
  EXTMEMB2 (rx) : ORIGIN = 0x00000000, LENGTH = 0
  EXTMEMB3 (rx) : ORIGIN = 0x00000000, LENGTH = 0
}

I am stuck at this point, and have so far been unable to find any resources pointing me in the right direction. Any ideas?

1
The Flash starting address is 0x08000000 for STM32, if the error is at 0x00000001 there is a possibility that you want to flash your program to the wrong place. There is an Address: field in ST-Link Utility, please tell me what address is visible in that?Bence Kaulics
Just look at the first two lines of your .hex file, it should look like :020000040800F2 <- there, 0800 is the high-order half of the starting address, :10000000FC3F0120A50A0008C90D0008950C000856 <- 0000 is the lower half. If there is something else, then your program is linked at the wrong address.followed Monica to Codidact
Adding your memory linker script would be helpful.Bence Kaulics
First two lines are :1000000000280020... and :10001000D9010000..., so I guess it is not linked correctlyArvest
after fixing the mem.ld address to 0x08000000, and changing to the correct gcc-arm-none-eabi compiler (oeps), the hex file now looks correct: :020000040800F2 :10000000002800205901000861010008650100086E, but error in ST-link utility remainsArvest

1 Answers

0
votes

ST Link utilty caches the files that you use. It's not documented anywhere but it does this. If you want to be 100% sure you've programmed the latest binary/hex file change the name of the file (from the previous version) and program again