Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

355
Visualizações
Writing on NVRAM through unsigned char* and unsigned int*

I'm developing under a linux embedded board I have a NVRAM where stores all my sensible data. I managed to access it via mmap /dev/mem, now the problem is writing, through an unsigned char* pointer there's no problem, but I need to write an entire structure, e.g.:

struct t_game_data
    {
    int energy;
    int bet;
    int coin;
    };

after mapping my memory with:

unsigned char* mem_ptr = (unsigned char*)mmap((void *)0x0, 512*1024, PROT_READ | PROT_WRITE,MAP_SHARED, fd, 0x90600000);

I can write on NVRAM with no problem via mem_ptr:

*mem_ptr++ = 1;
*mem_ptr++ = 2;
*mem_ptr++ = 3;
mem_ptr++;
*mem_ptr++ = 4;

// What i get reading NVRAM is(NVRAM is filled with 255 by default) 
1 2 3 255 4

But if I try to do something like this:

t_game_data* data = (t_game_data*)mmap((void *)0x0,512*1024, PROT_READ |PROT_WRITE, MAP_SHARED, fd, 0x90600000);

When I try to use data for writing I can't write on NVRAM properly, so I tried to use an unsigned int* just to understand the problem and I got something really strange:

unsigned int* mem_ptr_int = (unsigned int*)mmap((void *)0x0, 512*1024, PROT_READ | PROT_WRITE,MAP_SHARED, fd, 0x90600000);

*mem_ptr_int++ = 1;
*mem_ptr_int++ = 2;
*mem_ptr_int++ = 3;
mem_ptr_int++;
*mem_ptr_int++ = 4;

// What i get reading NVRAM is(NVRAM is filled with 255 by default) 
0 255 255 255 0 255 255 255  0 255 255 255 255 255 255 255 0

Perhaps there's some problem with addressing I'm hoping it's not a physical limit of hw;

Thank you in advance.

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda