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

121
Visualizações
Changing just one byte in SD card sector

I'm implementing FAT16 on SD card with Atmega328.

I often need to change just one or two bytes in the sector (512B region).

I know how Flash works and that it needs to overwrite entire sector at once, but I was wondering if there maybe was some special command that would make the card itself handle it?

The point is, the atmega has only 2k RAM, and allocating 512 just for a read-modify-write SD card buffer is very unfavorable. Is there no other way?

(PS. AFAIK the atmega can't natively have external ram)

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

ELM Petit FAT File System Module claims:

It can be incorporated into the tiny microcontrollers with limited memory even if the RAM size is less than sector size.

In fact:

  • Very small RAM consumption (44 bytes work area + certain stack).

It is open source; so you might take a look at how it does that (or just use it as-is).

The write function does have some significant restrictions, such as while it can modify a file, it cannot create or change the size of one - which is probably the compromise necessary to avoid sector buffers.

There is a full featured version of ELM FatFS, but that requires significantly more code and RAM space. The page also has links to the FAT32 specification, and some technical notes on how SD cards work which might be useful.

EDIT:

In fact this is not particularly helpful. Petit FAT's claim refers only to the filesystem layer itself, it does not include any hardware specific device driver, and for SD/MMC there is no getting away from the 512 byte read-modify-write cycle.

Although the AVR may not support memory-mapped external memory, one could use an external serial memory device such as a Cypress FRAM or nvSRAM to store the sector data; although being non-volatile, it may remove the need for SD altogether unless large removable media is specifically required.

over 4 years ago · Santiago Trujillo Relatório

0

YOu cannot changge just few bytes in a sector without reading/writing the the whole 512 bytes. So you actually do need the RAM for buffer.

However, there are ways to pre-alloc the filespace or update the FAT every some writes only. That will even conserve write cycles, but might result in data loss if power down before the FAT has been updated (however, it might not corrupt the filesystem if implemented properly).

As you state that these are cheap ArduinoNano (clones - supposedly), you could just use two of them interconnected with UART/SPI/i2C - whatever is available, even 8 bit bit-bang would work.

One does whateveryouwanttodo and the other is just for SD-card/FAT processing.

Reminds me of the Comodore 64 and its floppy-disc drive 1541 which also included a small CPU (well "MCU", but not single chip).

over 4 years ago · Santiago Trujillo Relatório
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