NetBurner 3.5.6
PDF Version
Get Application Image and Load it From a Web Server

LoadCodeFromServer

A NetBurner embedded application that demonstrates retrieving and loading new firmware images from a web server.

Overview

This application showcases how to perform over-the-air (OTA) firmware updates on NetBurner embedded devices. It connects to a web server, downloads a new application image, and loads it onto the device for execution.

Features

  • Network Initialization: Automatically initializes the network stack and waits for DHCP configuration
  • Web Client Functionality: Downloads files from web servers using HTTP GET requests
  • Authentication Support: Supports HTTP basic authentication for secured downloads
  • Firmware Update Process: Implements the complete OTA update workflow
  • Interactive Interface: Simple command-line interface for triggering updates

How It Works

  1. Network Setup: The application initializes the network stack and waits for an active network connection via DHCP
  2. URL Configuration: Constructs a platform-specific URL pointing to the firmware image on AWS S3
  3. User Interaction: Waits for user input to trigger the update process
  4. Download and Install: Downloads the new firmware image and attempts to install it
  5. Automatic Reboot: On successful installation, the device reboots with the new firmware

Usage

Basic Operation

  1. Deploy the application to your NetBurner device
  2. Connect to the device's console/terminal
  3. Wait for the network to initialize and receive a DHCP address
  4. When prompted, press 'U' to start the update process
  5. The application will download and install the new firmware

Console Output

The application provides detailed console output including:

  • Network initialization status
  • Update prompts and instructions
  • Download progress and results
  • Error messages if the update fails

Code Structure

Main Components

  • **UserMain()**: Primary application entry point that handles initialization and user interaction
  • **GetAndDisplay()**: Utility function for downloading and displaying web content (used for demonstration)
  • Network Stack: Utilizes NetBurner's built-in networking capabilities
  • HTTP Client: Uses NetBurner's webclient library for HTTP operations

Key Libraries Used

Configuration

The application is configured to download firmware from:

https://netburner-apps.s3.amazonaws.com/{PlatformName}/SimpleHtml.bin

Where {PlatformName} is automatically determined based on the target NetBurner platform.

Security Considerations

  • The application includes support for HTTP basic authentication
  • Downloads are performed over HTTPS for security
  • The update process includes validation to prevent corrupted installations

Error Handling

The application includes comprehensive error handling:

  • Network connectivity verification
  • HTTP request timeout handling (60 seconds)
  • Download validation
  • Graceful failure recovery with user feedback

Development Notes

  • System diagnostics are enabled for debugging (should be disabled in production)
  • HTTP diagnostics can be enabled by uncommenting diagnostic flags
  • The application uses a 5KB buffer for HTTP responses
  • Network timeout is set to 5 seconds for initial connection

Platform Compatibility

This application is designed for NetBurner embedded devices and requires:

  • NetBurner RTOS
  • Active network connection (Ethernet or WiFi)
  • Sufficient flash memory for firmware storage
  • Internet connectivity to reach the update server

Building and Deployment

  1. Ensure you have the NetBurner development environment set up
  2. Compile the application using the NetBurner toolchain
  3. Deploy to your NetBurner device using standard deployment methods
  4. Connect to the device console to interact with the application

Safety Notes

  • Backup Your Firmware: Always maintain a backup of your current firmware before performing updates
  • Stable Network: Ensure a stable network connection during updates to prevent corruption
  • Power Supply: Maintain stable power during the update process
  • Testing: Test updates in a development environment before deploying to production devices

Troubleshooting

Common Issues

  • Network Connection Failed: Verify DHCP configuration and network connectivity
  • Download Failed: Check internet connectivity and server availability
  • Update Failed: Ensure sufficient flash memory and stable power supply
  • Authentication Issues: Verify credentials if using authenticated downloads

Debug Options

Enable diagnostic output by uncommenting:

SetHttpUpDiag(true);
void SetHttpDiag(bool b)
Enable/disable Web Client HTTP diagnostics to the console port.

Example Output

Application started
Hit U to update from
[https://netburner-apps.s3.amazonaws.com/PLATFORM/SimpleHtml.bin]
Starting update process...
update returned /failed rv=0