I'm not able to erase flash sector in MKL03,error 0x20

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I'm not able to erase flash sector in MKL03,error 0x20

3,038 Views
diegocolombo
Contributor IV

Hi,i need help in erasing and writng some data in a  sector of this small microcontroller,MKL03Z8VFG4


i dont know where is my error,but probably is very big.
I'm trying to erase a sector using the fsl_flash component in KDS 3.0.0 with KSDK
Actually how dont'know exactly how to use this component.

FlashInit(&flash1_InitConfig0);
  PFlashGetProtection(&flash1_InitConfig0,&protect_state);
  __asm("cpsid i");
  i=FlashEraseSector(&flash1_InitConfig0,0x1C00,1024,FlashCommandSequence);
  __asm("cpsie i");

i results 0x20  
The settings of the Processor Expert are at low clock frequency(4 MHz core clock and 2 MHz bus clock).

I reserved a sector in Flash at 0x1C00,modifyng the linker file,

m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x000017F0
my_flash (RX) : ORIGIN = 0x00001C00, LENGTH = 0x00000400
at the beginning of this sector some data was written at programming time,so to check if erasing happens.

unsigned char __attribute__((section (".myBufSection"))) buf[150]={"abcdefghijklmno

In the . s files these ares the configuration settings
.section .FlashConfig, "a"
.long 0xFFFFFFFF
.long 0xFFFFFFFF
.long 0xFFFFFFFF
.long 0xFFFF3DFE

I think that the "3D" value has to do only with the NMI enable and boot options,
the FTFA_FPROTn register are all0xFFFFFFFF,meaning that no region is protected

The example project is attached, if someone kindly would chek it,thanks;it is from a project that i cleaned almost to essential just to test the flash functions.

Many thanks.

Labels (1)
0 Kudos
12 Replies

2,529 Views
diegocolombo
Contributor IV

Thanks,you are shurely right
Being always in hurry investing time is not so simple.Today,with MCUXpresso i still faced all the installation,SDK and plugin problems that happens when i'm alone and things don't go exactly as the video shows they should be.In other words,if one has someone at his side that has already faced all this problems everything is fixed,and the new environment shows all of its features,if not all this new stuff looks irritating,and one could miss the old Code Warrior for Microcontrollers 6.1.
Thanks again for your help.

0 Kudos

2,529 Views
mjbcswitzerland
Specialist V

Hi Diego

One must be careful to recognise the difference between "investing time" and "losing time".

Always rushing but not arriving is indeed frustrating....

Regards and good luck - I'm signing out of the thread.

Mark

0 Kudos

2,529 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Diego Colombo 

Have you checked the example provided with the SDK package? Is your Flash command sequence load in RAM in order to avoid write-read operations?

I saw that you are using SDK 1.3 with KDS 3.0. I highly recommend you to use the latest version of the SDK (V2.4) and use MCUXpresso IDE. This version has resolved many bugs and it has full support in the tools that we provide.

Best regards

Jorge Alcala

0 Kudos

2,529 Views
diegocolombo
Contributor IV

Hi Jorge ,thanks for helping me

"Have you checked the example provided with the SDK package? " No i did'nt.
I'm still a newbie with SDK,where can i find this example?Is it specifically for the FRDM-KL03Z board?
Normally i don't feel encouraged by examples taking for granted that one is working on a Freedom board,when i have the MKL03 mounted in a custom prototype,as i do,and i dont know the steps to clean the project by anything that involves the Freedom board.

I dont have an idea where the flash command sequence is,i just copied that few lines from somewhere.
If i check the declaration of   
FlashCommandSequence in my code i have a function where at firsr glance  i can't see none of the tipical flash commands that in the reference manual are under 27.4.8.2 Flash Commands

Thanks for your time

Diego Colombo

0 Kudos

2,529 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Diego

You can download the latest SDK in our Web page:

Welcome | MCUXpresso SDK Builder 

you can find the example under board/driver_examples/flash. Hope it helps you

Best regards

Jorge Alcala

2,529 Views
diegocolombo
Contributor IV
  1. Thanks for the hints,probably i 'm still not able to
    appreciate the great work behind uTasker,MCUXpresso and
    all this stuff,that is available for free, thanks to NXP
    and to lot of engineers.
    But this is very far from what i need:i'm using KDS,i
    don't want and i can't spend time right now to learn
    uTasker or install MCUXpresso,despite i know that soon i
    will have to do the latter,and absolutely i don't want to
    download anymore a project for a specific FRDM board to discover that then
    i ìm not able to use it for my custom board..
    Is it so impossible to find a very simple bare metal
    example that can be used with KDS and SDK 1.2.0 where a
    sector reserved for data could be erased?
  2. I attached a project,in the linker file i reserved the sector at 0x1C00 for test,after it was  filled of values,can someone kindly correct it ?
  3. Not only it does not erase the sector,but calling the function ends in DefaultISR: in the startup file,before executing the code copied in RAM
    Thanks
0 Kudos

2,529 Views
mjbcswitzerland
Specialist V

Hello Diego

I note that you have now invested 2 months trying to find a solution to erasing a sector. Although you may be frightened by other solutions, do note that you can have a complete working project in 15 minutes if you follow the instruction video(s) and if you have a professional need a setup for your board can be made for you so that there is also no risk to your project (see http://www.utasker.com/services.html)

Taking a quick look at the project that you have generated by PE I suspect that you have something set up incorrectly since there looks to be a missing register pointer:

FLASH_SSD_CONFIG flash1_InitConfig0 = {
    .ftfxRegBase = 0U,
    .PFlashBase  = 0U,
    .PFlashSize  = 8192U,
    .DFlashBase  = 0U,
    .DFlashSize  = 0x00U,
    .EERAMBase   = 0U,
    .EEESize     = 0x00U,
    .DebugEnable        = false,
    .CallBack = &flash1_Callback,
};   

I suspect that ftfxRegBase  should be pointing the the base address of the flash controller and not 0 so any attempted writes to the flash controller would cause a hard fault to be generated.

I have been involved with various KL03 product developments, whereby the KL03 is a fairly simple chip to use and such product developments don't usually take more than a couple of weeks to complete when using a quality framework. I therefore think that you need to identify a method that allows your to work effectively to avoid unnecessary project costs and delays, which look presently to be a serious issue.

Regards

Mark

0 Kudos

2,529 Views
diegocolombo
Contributor IV

Thanks Mark for your hints.

Actually i suspended it for 2 months being forced to follow other issues.Yesterday i restarted and yes,i spent lot of hours trying to get my project working,but i also dedicated some hours  to install KSDK 1.3.0 and practicing unsuccessfully with MCUXpresso.Solved a couple of hours ago,but still not explained.Tomorrow i will compare the bad example with the working one to find thecrucial difference.

I  extracted some functions call and definitions by an example :flash_example_frdmkl03z and i pasted in my project.Some definitions and some values filling structures are probably different from the ones in my example.

Let me check after some hours of sleep(1:30 AM here).
I wasted lot of time trying to have the example working,no way,despite the MKL03 library was compiled in my workspace i was not able to run the example:i have KDS 3.0 and th 3.2.In 3.0 i had     make:***Access denied
in 3:2 after restart some path looks missing,i don't know why,and all the projects in the workspace were not able to be compiled anymore because of  "arm-none-eabi-g++" not found in PATH ..".Same for "arm-none-eabi-gcc..."I was not able to find the missing or wrong field in Project Properties.
Then, MCU Expresso at first installation missed Kinetis Processors,and i don't have an idea about how to insert them.

I still don't understand the uTasker,some precomplied  .bin are offered,but what can i do a binary file?
I started with KDS and i want to solve with it.
Furthermore,even in minimal projects the debugger was not able to reset from start,falling in a loop that when stopped showed a message "no source available ...0x1C000xx".,and this every time i dare to press the reset button in the debug upper bar.

This is to say that i spent hours looking for infos about tools and libraries ,but i 'm still confused.

Thanks again

0 Kudos

2,529 Views
mjbcswitzerland
Specialist V

Diego

uTasker s not a .bin - it is a complete (free open source) project on Github or a profession version for those needing to have a guaranteed development solution with support (the bin is just an example of a working project that can be loaded to a reference board if of interest). It works with KDS, MCUXpresso, Codewarrior, IAR, Keil or others, so has no restrictions. It has tutorials, many documents and videos for those who need to get up to speed quickly. Free remote desk top introductions are available for those with professional needs or have training requirements.

It would give you an immediate and guaranteed solution if you were to invest a fraction of the time you have done in the no longer supported KDS and KSDKs and working out why its examples don't work.

Apart from debugging problems for you if you require use of the older examples (see the support page for more details of consulting service) I don't think I can help much more.

If you need to use NXP examples it would also make sense to follow their advice to use their latest library and tools since you will have more chance of obtaining some support that when using legacy ones that they will have no interest in maintaining.

Regards

Mark

2,529 Views
mjbcswitzerland
Specialist V

Hi Diego

Try also a binary from here - http://www.utasker.com/kinetis/FRDM-KL03Z.html
and see the video explaining Flash operations at https://www.youtube.com/watch?v=Pe9A8qsefzQ

Try the uTasker project (free open source) which contains flash API, parameter and file system for KL03 and allows flash simulation.

Regards

Mark

Flash: http://www.utasker.com/docs/uTasker/uTaskerFileSystem_3.PDF

uTasker - for more performance and faster, cheaper product development

2,529 Views
diegocolombo
Contributor IV

Thanks Mark,for introduce me in the uTasker world.I read that "the µTasker is an operating system with TCP/IP stack and USB support as well as drivers for various Internet/USB enabled single-chip microcontrollers"...but i'm still afraid that this is not what i need.
I'm in the middle of a baremetal small project where VLLS3 mode ,i dont' want to depend by an operating system,i 'm shure that if i would be able to use it i could find it useful in many situation,and i thank you very much but what i need now are,if possible,few rows of codes just to add some elementary flash saving of some tenth of bytes.
Probably my approach sounds demotivating to the guys that developed all this useful functions and structures granting portability,but because of my limits often i'm not able to extract exactly the few things i need from these professionally structured projects,when i try some definition results undeclared and so on

.Anyway i try to read and understand your link

Thanks very much

Diego

0 Kudos

2,529 Views
mjbcswitzerland
Specialist V

Hi Diego

The project is designed to be efficient and easy to use so if you have only worked with bare metal projects before you will still feel at home, but you will find that you can work faster and more modularly (as well as having quality drivers and support). It allows low power operation to be used very simply and can operate (due to small footprint) on anything from a KL02 up to a K70 with essentially the same application code (whereby the K70 - and other larger chips - would be able to take advantage of the integrated TCP/IP stack, USB, etc.).
- No code generation needed
- No different driver sets and BSPs for different target
- Project and chip simulation (including peripherals, interrupts, DMA, flash operations, etc.)

Regards

Mark