2024-04-29 07:34 PM
hello,
Now I'm trying to implement ML library created by NanoEdgeAI Studio to our STM32C0 target board.
My anomaly detection ML looks work fine at this time, but I wonder that every time after boot the system I have to learn normal case.
For our application, sometimes the system will shutdown while the work flows.
I also have tried 'Embedded Knowledge' option, but it's not as well so far.
So I want to save knowledge after learning while runtime on Real-target, and then it may work fine while the same work flows.
When the work to flow changed, then reset (or re-initialize) knowledge and learn normal case in work-setup procedure. hmm, sounds good.
Is this possible?
BR,
mxo
Solved! Go to Solution.
2024-05-02 02:25 AM - edited 2024-05-02 02:26 AM
Hello,
Your solution is great, thank you for the suggestion!
Regarding your questions, when you include the library neai.a, "neai" will appear both in FLASH and RAM. What we add in the linker script (.ld) is the KEEP:
.neai :
{
_sneai_knowledge = .; /* Start address of .neai section */
KEEP(*(.neai)) /* Keep my variable even if not referenced */
_eneai_knowledge = .; /* End address of .neai section */
} >RAM
It guarantees that the symbols are present, and it is also used to determine the start and end address of .neai section:
extern void *_sneai_knowledge;
extern void *_eneai_knowledge;
If you have other suggestion, please share it with us.
Best regards,
Julian
2024-04-30 01:08 AM - edited 2024-04-30 01:45 AM
Hello,
I attached an example to save the knowledge and reuse it.
Additionally, you can find information in the documentation:
AI:NanoEdge AI Library for anomaly detection (AD) - stm32mcu
Do not hesitate to contact me again if you need further assistance.
Best regards,
Julian
2024-04-30 08:16 PM - edited 2024-04-30 08:22 PM
Hello @Julian E.
Thank you for your assistance, and then I want to ask some more for my understandings.
I found that the section ".neai" as you mentioned in my libneai.a is already implemented in both FLASH and RAM.
(note that I implemented library with 'Embedded Knowledge' option.)
Q1.
Is step #2 of PDF instruction means that create another copy of .neai section in RAM, or only give name at existing .neai section ?
In the Wiki page, fixed address is given to .neai section in RAM, instead giving name.
I think giving name is better..
Q2.
According to step #3 & #4 of PDF instruction, knowledge is held as uint32_t array and it is ensized with WORD_SIZE to copy to/from FLASH, but is it right?
In conclusion, I guess that only an entire .neai section should be copied between FLASH & RAM.
Or (also concern with Q1), .neai in FLASH should be kept as is and only save copy of .neai RAM to disignated FLASH page, how is this?
Anyway, the solution is exactly what I want!
(quite little another thing but, the line of .neai section in the size list is deleted or hide between PDF pages.. oh, where is 136 sized??)
B.R.
mxo
2024-04-30 11:11 PM
Hello again,
I have just verified about .neai section.
Linker script is as following..
/* customize for NanoEdgeAI ML knowledge implementation */
.neai :
{
_neai_knowledge = .;
KEEP(*(.neai))
_eneai_knowledge = .;
} >RAM
then my main.c has..
extern void *_neai_knowledge; // for knowledge save & restore - section .neai start address
extern void *_eneai_knowledge; // - section .neai end address
#define NEAI_SectionSize ((unsigned int)&_eneai_knowledge - (unsigned int)&_neai_knowledge)
and my library is..
and take look after load..
and, OK, print section size to consle..
I believe this is better while determing section size.
B.R.
mxo
2024-05-02 02:25 AM - edited 2024-05-02 02:26 AM
Hello,
Your solution is great, thank you for the suggestion!
Regarding your questions, when you include the library neai.a, "neai" will appear both in FLASH and RAM. What we add in the linker script (.ld) is the KEEP:
.neai :
{
_sneai_knowledge = .; /* Start address of .neai section */
KEEP(*(.neai)) /* Keep my variable even if not referenced */
_eneai_knowledge = .; /* End address of .neai section */
} >RAM
It guarantees that the symbols are present, and it is also used to determine the start and end address of .neai section:
extern void *_sneai_knowledge;
extern void *_eneai_knowledge;
If you have other suggestion, please share it with us.
Best regards,
Julian
2024-05-06 05:37 PM
Hello,
Thank you for reviewing.
Now I'm almost clear about them except following one..
Is this definition comes from some FLASH limitation or only a mistake?
We are now trying to export and restore .neai section through serial communication port with binary dump method we have, and the dump size is only "NEAI_KNOWLEDGE_SIZE".
I believe that we're on right way at least while our trials, but I want to know if you have any other reasons about saving to FLASH.
B.R.
mxo
2024-05-07 05:02 AM - edited 2024-05-13 12:36 AM
Hello @mxo,
Here are some elements that may help you:
STM32F401xB/C and STM32F401xD/E advanced Arm®-based 32-bit MCUs - Reference manual
Best regards,
Julian
2024-05-07 05:13 PM
Hello @Julian E.
Thank you for your assistance and they lead our application better enough.
Later, I will verify FLASH R/W issue, that I think this is another issue and recently it dosen't matter about our application so far.
Again, thank you very much.
Best Regards.
mxo
2024-05-13 12:38 AM
Hello,
Your issue with the FLASH R/W is probably due to the WORDSIZE not being defined.
Good luck with your project and do not hesitate to contact us again if you encounter any other issues.
Best regards,
Julian