This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Writing variable in RAM after programming

Hello,

i want to write a global unsigned long variable in RAM after programming the device. The Use-Case is to set the clock value to the actual time. So the new unsigned long value will be generated from the host PC from the actual time. This new value should be set via the SWD interface. Is that possible by using the --ramwr option from nrfjprog.exe? We will use the Segger Flasher ARM.

Thanks and regards, BTprogrammer

Parents
  • Hi BTprogrammer

    You can write to RAM with using e.g.

    nrfjprog --ramwr 20007050  --val 0x12345678
    

    and read back the memory content with e.g.

    nrfjprog --memrd 20007000  --n 256
    

    Just make sure the application will not use the same RAM space, as it might overwrite your written value. Here is a thread that contains information about how the RAM space is constructed. This thread contains some info on how to configure the ROM and RAM space of the application in Keil. If you have e.g. the nRF51 QFAC chip with 32kB of RAM (the chip residing on nRF51-DK and nRF51-dongle development kits) then you can make the application use space from e.g. 0x20000000 to 0x20007000 and then you will have RAM memory space 0x20007000 to 20008000 untouched by the application.

    Update 1.9.2015 This thread contains only how to divide the RAM into sections. Right now, I am not sure how you would put a variable into a specific RAM location. It may be possible, perhaps others can step in and share their knowledge on that.

    Another option would be to use one of the onboard peripherals, like the UART, to write to A variable (in RAM or flash). You could have the UART hardwired to the PC or you could use virtual UART and transmit the value wirelessly over BLE if you have a BLE enabled PC. For that purpose, use the NUS service (Nordic UART Service over BLE) to transmit data over a BLE link. This example in nRF51 SDK 9.0.0 implements both the actual UART to communicate with PC and the BLE UART (NUS service)

    You could also use pstorage RAW mode (when BLE softdevice enebled) or NVMC (no softdevice enabled) to write directly to an address in flash memory from you program, and also write to the same address with nrfjprog --memwr command from PC.

  • Hello Stefan, thank you for your answer and sorry for my late reply. As I mentioned, I want to use the --ramwr option to manipulate one of my global application variables. So the workflow will be: 1. Put the CPU into halt state . 2. Manipulate the specific RAM value. 3. Let the CPU run. Am I right!?

    Another question, how can I get the RAM address of the global variable!? printf("address: %p", variable); didnt`t work. Regards, BTprogrammer

Reply
  • Hello Stefan, thank you for your answer and sorry for my late reply. As I mentioned, I want to use the --ramwr option to manipulate one of my global application variables. So the workflow will be: 1. Put the CPU into halt state . 2. Manipulate the specific RAM value. 3. Let the CPU run. Am I right!?

    Another question, how can I get the RAM address of the global variable!? printf("address: %p", variable); didnt`t work. Regards, BTprogrammer

Children
No Data
Related