README.displaying-bmps 1.2 KB

123456789101112131415161718192021222324252627
  1. If you are experiencing hangups/data-aborts when trying to display a BMP image,
  2. the following might be relevant to your situation...
  3. Some architectures cannot handle unaligned memory accesses, and an attempt to
  4. perform one will lead to a data abort. On such architectures it is necessary to
  5. make sure all data is properly aligned, and in many situations simply choosing
  6. a 32 bit aligned address is enough to ensure proper alignment. This is not
  7. always the case when dealing with data that has an internal layout such as a
  8. BMP image:
  9. BMP images have a header that starts with 2 byte-size fields followed by mostly
  10. 32 bit fields. The packed struct that represents this header can be seen below:
  11. typedef struct bmp_header {
  12. /* Header */
  13. char signature[2];
  14. __u32 file_size;
  15. __u32 reserved;
  16. __u32 data_offset;
  17. ... etc
  18. } __attribute__ ((packed)) bmp_header_t;
  19. When placed in an aligned address such as 0x80a00000, char signature offsets
  20. the __u32 fields into unaligned addresses (in our example 0x80a00002,
  21. 0x80a00006, and so on...). When these fields are accessed by U-Boot, a 32 bit
  22. access is generated at a non-32-bit-aligned address, causing a data abort.
  23. The proper alignment for BMP images is therefore: 32-bit-aligned-address + 2.