GD32 - writing program ram

Boards based on the GigaDevices GD32F103 microcontroller
User avatar
Pito
Posts: 1625
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

GD32 - writing program ram

Post by Pito » Wed May 04, 2016 8:43 am

Hi, I've tried to find a datasheet but except a marketing document called datasheet I have not find any.
So my Q to a more lucky GD users - is it possible to write/read into the program ram (64/128kB)?
P.
Pukao Hats Cleaning Services Ltd.

User avatar
RogerClark
Posts: 7422
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: GD32 - writing program ram

Post by RogerClark » Wed May 04, 2016 11:05 am

What do you mean by program RAM ?

Do you mean the EEPROM or the few bytes of non volatile RAM

I doubt the GD32 is different from the STM32 in how you write to either, in fact the Bootloader , which writes to EEPROM is a direct copy of the STM32 bootloader.

If you mean non volatile RAM, I vaguely recall looking something on the forum about it, as it may have been useful for signalling from the sketch to the bootloader, but we never ended up using it for that, and I don't think anyone else uses it.
But if anyone knows about NV RAM I think it would be @ahull

User avatar
Pito
Posts: 1625
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: GD32 - writing program ram

Post by Pito » Wed May 04, 2016 2:37 pm

GD is a flashless chip.
There is a second one chip glued on top of the arm - a 128kB SPI flash, and the 8pin serial flash is bonded to the arm.
Upon boot the GD reads the SPI flash into the Program RAM - there is 128kB large "program RAM".
It runs the program out of the program RAM then. Therefore 0 waitstates. And other implications too - ie writing to flash might be slow..

My Q is about writing/reading the 128KB Program RAM (not r/w to the external flash chip or 20kB ram).
Last edited by Pito on Wed May 04, 2016 2:43 pm, edited 1 time in total.
Pukao Hats Cleaning Services Ltd.

User avatar
ahull
Posts: 1648
Joined: Mon Apr 27, 2015 11:04 pm
Location: Sunny Scotland
Contact:

Re: GD32 - writing program ram

Post by ahull » Wed May 04, 2016 2:43 pm

Pito wrote:GD is a flashless chip. There is a second one chip glued on top of the arm - a 128kB SPI flash, and the 8pin serial flash is bonded to the arm. Upon boot the GD reads the SPI flash into the Program RAM - there is 128kB large RAM. It runs the program out of the program RAM then. Therefore 0 waitstates. And other implications too - ie writing to flash might be slow..
My Q was about the 128KB Program RAM.
If you read the GD documentation, so far as I recall it mentions where in the ARM address space the RAM lives, I suspect you should be able to examine and change it simply by accessing the correct address space, however I haven't verified this.
- Andy Hull -

User avatar
Pito
Posts: 1625
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: GD32 - writing program ram

Post by Pito » Wed May 04, 2016 2:51 pm

We need a good RefMan for this, I cannot find any. Writing to the "program space" would most probably end with writing to the external flash. And maybe to the ram as well. Unless there is a "switch" for ram access only .. Thinking on bypassing the flash.. Would be great to have a GD32 chip without flash chip bonded. So I can load/store binaries out of an external SPI FRAM/SRAM/MRAM, or modify the program in prog_RAM on the fly... 8-)
Pukao Hats Cleaning Services Ltd.

User avatar
WereCatf
Posts: 166
Joined: Sat Apr 16, 2016 5:30 pm

Re: GD32 - writing program ram

Post by WereCatf » Wed May 04, 2016 3:20 pm

Pito wrote:GD is a flashless chip.
There is a second one chip glued on top of the arm - a 128kB SPI flash, and the 8pin serial flash is bonded to the arm.
Upon boot the GD reads the SPI flash into the Program RAM - there is 128kB large "program RAM".
It runs the program out of the program RAM then. Therefore 0 waitstates.
Huh, that's an interesting approach. I suppose you learn something new every day. :shock:

User avatar
martinayotte
Posts: 1229
Joined: Mon Apr 27, 2015 1:45 pm

Re: GD32 - writing program ram

Post by martinayotte » Wed May 04, 2016 3:35 pm

Yes, that was interesting when it came out :
http://zeptobars.com/en/read/GD32F103CB ... ga-Devices

User avatar
Pito
Posts: 1625
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: GD32 - writing program ram

Post by Pito » Wed May 04, 2016 6:54 pm

Yea, we discussed that a month ago in "How the chip works" topic..
Pukao Hats Cleaning Services Ltd.

racemaniac
Posts: 617
Joined: Sat Nov 07, 2015 9:09 am

Re: GD32 - writing program ram

Post by racemaniac » Wed May 04, 2016 7:41 pm

I've recently been working with some flash chips, and if the flash in the GD32 is anything like the other flash i've seen so far, it won't be as simple as writing to a certain memory address. To write to a section of the flash you have to clear it first (and this is thus not just the bits you want, it has to be at least a page), and then write the data you want (also usually page per page). On the 4Mb chip i have the page size is 256 bytes. and writing is pretty slow since clearing such a page takes 40ms.
Reading however is fast :).

*edit*
i just read it's mirrored to sram, that is indeed interesting XD

User avatar
martinayotte
Posts: 1229
Joined: Mon Apr 27, 2015 1:45 pm

Re: GD32 - writing program ram

Post by martinayotte » Wed May 04, 2016 7:48 pm

It is not even sure that the mechanics are available on CPU side, transfers could be done in hardware for both direction and RAM still been seen as emulated flash compatible with the STM one, in the case of F1xxx, with 1KB pages.

Post Reply