2025-04-16 7:21 PM
I want to use the STM32F407 to implement the NanoEdge AI Library for Anomaly Detection (AD) tasks.
The documentation mentions nanoedge.ai's method for backing up and restoring the library knowledge using the .ld file in a Linux environment. I want to know how to perform this backup operation in Keil.
Solved! Go to Solution.
2025-04-17 2:15 AM
If you're just experimenting, accessing the address via .map is fine.
But for production firmware, we would recommend to:
extern const uint8_t __start_myKnowledge__;
extern const uint8_t __end_myKnowledge__;
Then compute size at runtime:
size_t size = &__end_myKnowledge__ - &__start_myKnowledge__;
The risks of not using the Scatter File are:
1.Uncontrolled Placement
2.Optimization & Linker Shifts
3.Risk of Overlap
4.Upgrade & Maintenance Issues
So it depends on what you are doing.
Have a good day,
Julian
2025-04-17 1:18 AM
Hello @ygh2048,
It seems that the equivalent of a .ld file in CubeIDE is a .sct (scatter file) in keil.
Let’s say in STM32CubeIDE you had something like this in your .ld
script:
ldCopyEdit.myKnowledge (NOLOAD) :
{
KEEP(*(.myKnowledge))
} >FLASH
In Keil’s scatter file, you can do the equivalent:
1. Open / Create your scatter file (e.g., stm32f4xx_flash.sct)
2. Add your flash region inside the LR_IROM1 load region:
sctCopyEditLR_IROM1 0x08000000 0x00100000 { ; load region (1MB flash)
ER_IROM1 0x08000000 0x00080000 { ; main code section (512 KB)
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
}
RW_IRAM1 0x20000000 0x00020000 { ; RAM
.ANY (+RW +ZI)
}
;Add your custom flash knowledge section here
ER_KNOWLEDGE 0x08080000 0x00010000 { ; 64 KB for knowledge
*.o (.myKnowledge) ; or whatever your section name is
}
}
3. Use attribute in your C file to place variables there:
In your .c file:
cCopyEdit__attribute__((section(".myKnowledge"))) const uint8_t learned_data[] = { ... };
Keil will place learned_data[] into your custom ER_KNOWLEDGE region at address 0x08080000.
Have a good day
Julian
2025-04-17 1:59 AM
Hello, thank you for your previous answer—it was very helpful. Additionally, I would like to ask for further clarification about this issue.
I noticed that when using Keil, I can directly retrieve the address and size of the .neai variable from the generated .map file. If I use this address directly for backup purposes, would this achieve the same effect while avoiding involvement with the scatter file (.sct)? Does this approach have any potential flaws or oversights?
2025-04-17 2:15 AM
If you're just experimenting, accessing the address via .map is fine.
But for production firmware, we would recommend to:
extern const uint8_t __start_myKnowledge__;
extern const uint8_t __end_myKnowledge__;
Then compute size at runtime:
size_t size = &__end_myKnowledge__ - &__start_myKnowledge__;
The risks of not using the Scatter File are:
1.Uncontrolled Placement
2.Optimization & Linker Shifts
3.Risk of Overlap
4.Upgrade & Maintenance Issues
So it depends on what you are doing.
Have a good day,
Julian