Application Image Checksum
Overview
This application demonstrates how to read and display the flash application image checksum at runtime. The checksum provides a way to verify the integrity of the application image stored in flash memory.
Features
- Reads the application image checksum from the running application header
- Displays application build information including name and NNDK revision
- Starts an HTTP server for web-based access to checksum information
- Provides both console output and web interface variables
How It Works
The application uses the NetBurner RTOS system to access the running application image header structure. The checksum is retrieved from the dwImgSum
field of the application header and displayed in hexadecimal format.
Key Components
- main.cpp: Main application code that initializes the system and retrieves the checksum
- htmlvar.h: Header file declaring web interface variables
Checksum Access
The application checksum can be accessed at runtime by including the startup.h
header and reading from the RunningAppImage
structure:
#include <startup.h>
printf("Application Checksum: %#08lx\r\n", RunningAppImage->appHdr.dwImgSum);
Build Process Verification
When building the application, the flashpack
utility displays the image checksum in its output. This allows you to verify that the runtime checksum matches the build-time checksum.
Example flashpack output:
App Header:
Image Address: 0x0040801c
Exec Address: 0x70000001
pExtra: 0x0040801c
Image Length: 0x0007adb0
Image Checksum: 0xc585db80
Header Checksum: 0x0c46c8e5
Raw image size: 646688 bytes
Compressed size: 503106 bytes
The Image Checksum
line shows the checksum value that should match the runtime value.
Application Output
The application provides the following information:
- Console Output: Displays app name, NNDK revision, and checksum via printf statements
- Web Variables: Makes checksum and app info available through HTML variables:
strAppInfo
: Contains app name and NNDK revision
strAppChecksum
: Contains the hexadecimal checksum value
System Requirements
- NetBurner RTOS system
- Network connectivity for HTTP server functionality
- Flash memory with valid application image
Usage
- Build and flash the application to your NetBurner device
- Connect to the device via serial console to see the output
- Access the HTTP server to view checksum information via web interface
- Compare the runtime checksum with the build-time checksum from flashpack output
Security Considerations
The image checksum provides a basic integrity check for the application image. It can help detect:
- Corruption of the flash memory
- Incomplete or failed firmware updates
- Tampering with the application image
For production systems, consider removing the EnableSystemDiagnostics()
call as noted in the code comments.
Technical Details
- The application runs in an infinite loop with 1-second delays
- Network initialization waits up to 5 seconds for active network
- HTTP server is started automatically for web interface access
- Checksum is displayed as an 8-digit hexadecimal value with 0x prefix