Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

347
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda