2022-04-27 01:08 PM
I'm totally new on stm32 mcu's. i was working on a project and i want to update the MCU(The previous MCU was AVR) and i want to encode and decode base64 using Stm32CubeIDE(HAL Driver), so i decide to port my arduino library. The library is attached, but i have a problem in porting library. there is an include and function in the arduino library and i don't know how to port this part of code:
First part:
#include <avr/pgmspace.h>
const char PROGMEM b64_alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
and this function
pgm_read_byte(&b64_alphabet[a4[i]]).
The original library file is attached. Please help me. i dont know what should i do for this.
Solved! Go to Solution.
2022-04-27 02:07 PM
Shouldn't need different memory spaces, compiler/linker should fold things like this in the FLASH/ROM section, without extra direction, and you should be able to access like a normal C array
const char b64_alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
output[encLen++] = b64_alphabet[a4[j]];
To direct things to different sections described in the linker script you'd use an __attribute__((section("name"))) type construct, or #pragma
2022-04-27 02:07 PM
Shouldn't need different memory spaces, compiler/linker should fold things like this in the FLASH/ROM section, without extra direction, and you should be able to access like a normal C array
const char b64_alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
output[encLen++] = b64_alphabet[a4[j]];
To direct things to different sections described in the linker script you'd use an __attribute__((section("name"))) type construct, or #pragma
2022-04-28 02:12 AM
Tnx @Community member , but this library doesnt work. can i run any C code on stm32? so i just need to find a base64 library in C and import it in my project? i'm confused (noobie here :). ) some commands are used in base64 algorithms like malloc() . do this work on STM32? or i should modify C codes to run on STM32?
2022-04-28 02:22 AM
malloc/free are typically available, but the heap can be fairly small depending on compiler and libraries.
You should be able to port the base 64 code without using the PGMSPACE/PRGMEM stuff.