cancel
Showing results for 
Search instead for 
Did you mean: 

How to store web pages in microcontroller flash

bikash
Associate II
Posted on September 26, 2012 at 14:37

Hello all,

I am doing a project where the microcontroller (STM32) is sending the parameters to the server via DHCP using wifi module. So, now i want to make available an offline web page to the user where he will put the SSID and phrase of the DHCP. This web page will be stored in the microcontroller and when the user connects the device to the PC using USB, folder containing this webpage should appear on the screen.

Can anybody help me out on how do i do this?

Thank you.

#learn-to-walk-before-running #dhcp #drowning #drowning #http #html
10 REPLIES 10
crt2
Associate II
Posted on September 26, 2012 at 15:37

Probably easiest concept would be that you store the html binary file into flash (using arm-none-eabi-objcopy) and then just transfer it through wifi to user. I do not know what wifi module makes (probably some tcp/ip stack) but you might have to pay attention to headers and wrappers.

Posted on September 26, 2012 at 16:23

How to store web pages in microcontroller flash

The same way you'd store any kind of data. The memory is byte addressable like all other memory in the system. The writing requires blank/erased pages, and to communicate with the flash controller. You should review the Programming Manual PM00xx for whichever specific STM32 part you're using, and you should review the example code in the firmware libraries.

To get a PC to read it, you'll perhaps need to look at the MSC USB examples, and use FatFs, or perhaps CDFS, to create a faux file system image for the PC to navigate and find files. 

For static file data, you could always make a file system image during your application build process, and perhaps form data structures and generate .C or .H files to be pulled in by the compiler. If you understand your tool chain or linker, you could perhaps pull binary file images in directly.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Evangelist III
Posted on September 26, 2012 at 19:50

''i want to make available an offline web page to the user''

So you need a Web Server   in your device; or, more precisely, and HTTP server.

Here is an excellent tutorial on HTTP:

http://www.jmarshall.com/easy/http/

''store the html binary file into flash''

Note that HTML is just plain text - so you can store simple web pages just as 'C' strings; eg,

char web_page[] =

''<html>''

''<head>''

''<title>Simple web page</title>''

''</head>''

''<body>''

''<p>Hello, HTML Web World!</p>''

''</body>''

''</html>'';

bikash
Associate II
Posted on September 27, 2012 at 13:27

I would like to clear the application once again because there is a little change in the implementation.I want to Access offline web pages in the SD card connected to micro controller(stm32f100) from PC using USB.

Thanks for the reply

Posted on September 27, 2012 at 15:48

So you want the USB to act like an Ethernet/Webserver, or Mass Storage/File System?

On an SDCard you could just build the web content as you would on a Flash drive, or CD, in the same way people put HTML content of a Evaluation Board CD, or VL-Discovery.

Is this a commercial project?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
crt2
Associate II
Posted on September 27, 2012 at 15:51

That one is even simpler. I do not know how will you connect through usb with browser but when you send some command (can also be HTTP with file request embedded) uC will just need to check filenames on SD card and pick the right one and then send it back through USB (you can say it will copy it). Since I think you tend to make multiple web pages then you might want to just send them through byte by byte without saving anything in flash or memory at all.

Andrew Neil
Evangelist III
Posted on September 27, 2012 at 21:42

''On an SDCard you could just build the web content as you would on a Flash drive, or CD, in the same way people put HTML content of a Evaluation Board CD''

 

But that only works for static pages;  no use for the user to input data to thesystem - which was the OP's original requirement...
Posted on September 27, 2012 at 22:24

But that only works for static pages;  no use for the user to input data to the system - which was the OP's original requirement...

I was addressing the ''how do I store'' aspect of this rather contorted question.

On further examination, a webserver might be the approach, capable of HTTP GET/PUT, but the whole attach to a PC, offline content, and remember parameters situation muddies the water further.

The OP needs to better define and understand the problem, come up with a clear/workable plan of attack, and staff the project with people capable of executing the plan.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Evangelist III
Posted on September 29, 2012 at 12:40

''the whole attach to a PC, offline content, and remember parameters situation muddies the water''

 

 

Indeed.

''The OP needs to better define and understand the problem, come up with a clear/workable plan of attack...''

 

Absolutely.

''...and staff the project with people capable of executing the plan''

Or, at the very least, include a significant training stage at the start of the project!