Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data flash not programmed #9

Open
bicyclesonthemoon opened this issue Jun 6, 2017 · 10 comments
Open

Data flash not programmed #9

bicyclesonthemoon opened this issue Jun 6, 2017 · 10 comments

Comments

@bicyclesonthemoon
Copy link
Contributor

I have noticed that only the code flash is erased, programmed and verified.
The data flash is not.

I looked into rl78.c and I saw things like this:

int rl78_program(port_handle_t fd, void *code, unsigned int code_size, void *data, unsigned int data_size)
{
// Suppress "unused variable" warnings
(void)data;
(void)data_size;

which suggests that this is a feature that has been skipped on purpose, for later.
I this true?

Do you have plans to implement this?
Or maybe for some reason it was not possible to implement?

It is important for me to have this working.
I want not to need E1 programmers any more.
And the devices we are programming also need the data flash to be programmed.

If you are not planning to implement this then I might consider making a fix myself.
But I'm not familiar with your code so I would not be very effective.

@msalau
Copy link
Owner

msalau commented Jun 8, 2017

Hi @bicyclesonthemoon

Indeed, data programming is not implemented. If you are OK to wait few days, I can prepare a version to try. Changes don't seem to be significant.

Thanks,
Maksim

@bicyclesonthemoon
Copy link
Contributor Author

Yes, of course it is ok to wait for this.
I am ready to test this it when it is done.
Thank you for the answer.

@msalau
Copy link
Owner

msalau commented Jun 11, 2017

Hi @bicyclesonthemoon

Please try the v0.6.0-initial-data-flash-support tag. It works for me (erase, write and verify).

Regards,
Maksim.

@bicyclesonthemoon
Copy link
Contributor Author

bicyclesonthemoon commented Jun 12, 2017

After a first test this seems to work correctly.
I programmed the mcu with rl78flash and verified it with E1.
I programmed the mcu eith E1 and verified it with rl78flash.
It worked correctly.

(I had to program it with -ewc, without -r and to verify it with -dc because the software on the mcu overwrites the data flash on first run)

Later I will prepare a special test file which requires the whole flash to be written, then I will be sure that this works. (because the file I tested it with had all the data flash empty (all 0xFFs))

Edited to add:
I tested this with a test file that I prepared and I'm having a problem with verification.
It is successful if I use -ewc but it fails if later I use -c. The verification with an E1 is still successful.

d:\b\testhex>d:\b\rl78flash\rl78flash.exe -ivvewc COM1 test.mot
Device: R5F104GJ
Code size: 256 kB
Data size: 8 kB
Erase code flash
................................................................................
................................................................................
................................................................................
................
Erase data flash
........
Read file "test.mot"
Write code flash
********************************************************************************
********************************************************************************
********************************************************************************
****************
Write data flash
********
Verify Code flash
********************************************************************************
********************************************************************************
********************************************************************************
****************
Verify Data flash
********


d:\b\testhex>d:\b\rl78flash\rl78flash.exe -ivvc COM1 test.mot
Device: R5F104GJ
Code size: 256 kB
Data size: 8 kB
Read file "test.mot"
Verify Code flash
FAILED
Block content does not match (000000)

Code flash verification failed

This is my test file which fills the whole flash space. It doesn't write actual code. It writes 00000.... to the first 32 bytes, 002000200020... to the next 32 bytes, 004000400040... to the next and so on:
test.mot.txt

This is the result of the -ivvvvewc command:
test1.txt

This is the result of the -ivvvvc command:
test2.txt

Another thing I see with my test file that If there was an erase, the write fails, so every second write is a fail:

d:\b\testhex>d:\b\rl78flash\rl78flash.exe -ivvew COM1 test.mot
Device: R5F104GJ
Code size: 256 kB
Data size: 8 kB
Erase code flash
*************************************************************...................
................................................................................
................................................................................
................
Erase data flash
........
Read file "test.mot"
Write code flash
FAILED
Programming failed (000000)

Code flash write failed


d:\b\testhex>d:\b\rl78flash\rl78flash.exe -ivvew COM1 test.mot
Device: R5F104GJ
Code size: 256 kB
Data size: 8 kB
Erase code flash
................................................................................
................................................................................
................................................................................
................
Erase data flash
........
Read file "test.mot"
Write code flash
********************************************************************************
********************************************************************************
********************************************************************************
****************
Write data flash
********


d:\b\testhex>d:\b\rl78flash\rl78flash.exe -ivvew COM1 test.mot
Device: R5F104GJ
Code size: 256 kB
Data size: 8 kB
Erase code flash
********************************************************************************
********************************************************************************
********************************************************************************
****************
Erase data flash
********
Read file "test.mot"
Write code flash
FAILED
Programming failed (000000)

Code flash write failed


d:\b\testhex>d:\b\rl78flash\rl78flash.exe -ivvew COM1 test.mot
Device: R5F104GJ
Code size: 256 kB
Data size: 8 kB
Erase code flash
................................................................................
................................................................................
................................................................................
................
Erase data flash
........
Read file "test.mot"
Write code flash
********************************************************************************
********************************************************************************
********************************************************************************
****************
Write data flash
********

Edited to add: This are the outputs from both situations:
fail.txt
success.txt

@msalau
Copy link
Owner

msalau commented Jun 19, 2017

Hi,

I'm on vacation at the moment, and will be able to take care of the issue after the 26th of June.

Regards,
Maksim.

@msalau
Copy link
Owner

msalau commented Jul 4, 2017

It seems the issue is in timeouts (not long enough).
The code should be reworked to honor individual timeout requirements for all commands according to chapter 5.1.1 of the spec.

@msalau
Copy link
Owner

msalau commented May 12, 2018

Hi @bicyclesonthemoon

I've merged the current version to master. The feature is included in v0.6.1.

Regards,
Maksim.

@bicyclesonthemoon
Copy link
Contributor Author

Recently I found out that the "problem" of not programming the data flash could actually be a useful feature.
I had a problem where my device was resetting on startup for some values of data flash content.
I could reprogram the device with a software which sends the data flash content through a serial interface to allow debugging.
Because of not programming the data flash, after I reprogrammed with the different software, the data flash content was preserved.

I made for myself a modification of newest rl78flash where I added two commandline options:
one to disable erasing writing and verifying of program flash and one for data flash.

It is very useful for debugging to reprogram the data flash without changing program flash or reprogram program flash without changing data flash or just erase data flash to simulate a device that just came out of factory and was never turned on yet.

Maybe it would be good to have the possibility of disabling data or program flash in official rl78flash release?

@msalau
Copy link
Owner

msalau commented Jan 7, 2019

Hi @bicyclesonthemoon

A command line option to disable programming of data flash is very useful.
I'd be glad to merge it into my repo. Please open a pull-request, or just attach a patch to a comment.
I think the feature may be exended a little bit more: we can decide which regions are flashed: data, code or both.

Thanks!

Regards,
Maksim

@bicyclesonthemoon
Copy link
Contributor Author

I'm not very familiar with github and pull requests yet.
Here are my changes in main.c, compared to current revision:
main.c.diff.txt

I added two commandline options. -x and -y.
And two variables char nodata and char nocode.
Using -x will disable any data flash operations.
Using -y will disable any code flash operations.

bicyclesonthemoon added a commit to bicyclesonthemoon/rl78flash that referenced this issue Jan 14, 2019
I added the possibility to disable data flash or code flash operations as commented on issue msalau#9

I added two commandline options. -x and -y.
And two variables char nodata and char nocode.
Using -x will disable any data flash operations.
Using -y will disable any code flash operations.
msalau pushed a commit that referenced this issue Jan 15, 2019
I added the possibility to disable data flash or code flash operations as commented on issue #9

I added two commandline options. -x and -y.
And two variables char nodata and char nocode.
Using -x will disable any data flash operations.
Using -y will disable any code flash operations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants