forked from maxnet/pico-webserver
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
10,197 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build | ||
makefsdata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[submodule "tinyusb"] | ||
path = tinyusb | ||
url = https://github.com/raspberrypi/tinyusb.git | ||
branch = pico | ||
[submodule "pico-sdk"] | ||
path = pico-sdk | ||
url = https://github.com/raspberrypi/pico-sdk.git | ||
[submodule "lwip"] | ||
path = lwip | ||
url = https://git.savannah.nongnu.org/git/lwip.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
cmake_minimum_required(VERSION 3.13) | ||
|
||
# We prefer to have all linked submodules at toplevel | ||
set(PICO_TINYUSB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/tinyusb) | ||
|
||
include(pico-sdk/pico_sdk_init.cmake) | ||
project(pico_webserver) | ||
pico_sdk_init() | ||
|
||
# LWIP | ||
set(LWIP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lwip) | ||
set (LWIP_INCLUDE_DIRS | ||
"${LWIP_DIR}/src/include" | ||
"${CMAKE_CURRENT_SOURCE_DIR}" | ||
) | ||
include(${LWIP_DIR}/src/Filelists.cmake) | ||
|
||
# Extra stuff from TinyUSB, that is not part of tinyusb_device library | ||
set(TINYUSB_LIBNETWORKING_SOURCES | ||
${PICO_TINYUSB_PATH}/lib/networking/dhserver.c | ||
${PICO_TINYUSB_PATH}/lib/networking/rndis_reports.c | ||
) | ||
|
||
add_executable(${PROJECT_NAME} webserver.c tusb_lwip_glue.c usb_descriptors.c ${TINYUSB_LIBNETWORKING_SOURCES}) | ||
|
||
pico_enable_stdio_usb(${PROJECT_NAME} 0) | ||
pico_enable_stdio_uart(${PROJECT_NAME} 0) | ||
target_include_directories(${PROJECT_NAME} PRIVATE ${LWIP_INCLUDE_DIRS} ${PICO_TINYUSB_PATH}/src ${PICO_TINYUSB_PATH}/lib/networking) | ||
target_link_libraries(${PROJECT_NAME} pico_stdlib pico_unique_id tinyusb_device lwipallapps lwipcore) | ||
pico_add_extra_outputs(${PROJECT_NAME}) | ||
target_compile_definitions(${PROJECT_NAME} PRIVATE PICO_ENTER_USB_BOOT_ON_EXIT=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,35 @@ | ||
# pico-webserver | ||
# pico-webserver | ||
|
||
Webserver example that came with TinyUSB slightly modified to run on a Raspberry Pi Pico. | ||
Lets the Pico pretend to be a USB Ethernet device. Runs a webinterface at http://192.168.7.1/ | ||
|
||
## Build dependencies | ||
|
||
On Debian: | ||
|
||
``` | ||
sudo apt install git build-essential cmake gcc-arm-none-eabi | ||
``` | ||
|
||
Your Linux distribution does need to provide a recent CMake (3.13+). | ||
If not, compile [CMake from source](https://cmake.org/download/#latest) first. | ||
|
||
## Build instructions | ||
|
||
``` | ||
git clone --depth 1 https://github.com/maxnet/pico-webserver | ||
cd pico-webserver | ||
git submodule update --init --depth 1 | ||
mkdir -p build | ||
cd build | ||
cmake .. | ||
make | ||
``` | ||
|
||
Copy the resulting pico_webserver.uf2 file to the Pico mass storage device manually. | ||
Webserver will be available at http://192.168.7.1/ | ||
|
||
Content it is serving is in /fs | ||
If you change any files there, run ./regen-fsdata.sh | ||
|
||
By default it shows a webpage that led you toggle the Pico's led, and allows you to switch to BOOTSEL mode. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, | ||
* are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* 3. The name of the author may not be used to endorse or promote products | ||
* derived from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT | ||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | ||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY | ||
* OF SUCH DAMAGE. | ||
* | ||
* This file is part of the lwIP TCP/IP stack. | ||
* | ||
* Author: Adam Dunkels <[email protected]> | ||
* | ||
*/ | ||
#ifndef __CC_H__ | ||
#define __CC_H__ | ||
|
||
//#include "cpu.h" | ||
|
||
typedef int sys_prot_t; | ||
|
||
|
||
|
||
/* define compiler specific symbols */ | ||
#if defined (__ICCARM__) | ||
|
||
#define PACK_STRUCT_BEGIN | ||
#define PACK_STRUCT_STRUCT | ||
#define PACK_STRUCT_END | ||
#define PACK_STRUCT_FIELD(x) x | ||
#define PACK_STRUCT_USE_INCLUDES | ||
|
||
#elif defined (__CC_ARM) | ||
|
||
#define PACK_STRUCT_BEGIN __packed | ||
#define PACK_STRUCT_STRUCT | ||
#define PACK_STRUCT_END | ||
#define PACK_STRUCT_FIELD(x) x | ||
|
||
#elif defined (__GNUC__) | ||
|
||
#define PACK_STRUCT_BEGIN | ||
#define PACK_STRUCT_STRUCT __attribute__ ((__packed__)) | ||
#define PACK_STRUCT_END | ||
#define PACK_STRUCT_FIELD(x) x | ||
|
||
#elif defined (__TASKING__) | ||
|
||
#define PACK_STRUCT_BEGIN | ||
#define PACK_STRUCT_STRUCT | ||
#define PACK_STRUCT_END | ||
#define PACK_STRUCT_FIELD(x) x | ||
|
||
#endif | ||
|
||
#ifndef LWIP_PLATFORM_ASSERT | ||
#define LWIP_PLATFORM_ASSERT(x) do { if(!(x)) while(1); } while(0) | ||
#endif | ||
|
||
#endif /* __CC_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | ||
"http://www.w3.org/TR/html4/strict.dtd" | ||
> | ||
<html lang="en"> | ||
<head> | ||
<title>Welcome to your Pico</title> | ||
</head> | ||
<body> | ||
|
||
<center> | ||
<h1>Welcome to your Pico!</h1> | ||
|
||
<!-- Image Map Generated by http://www.image-map.net/ --> | ||
<img src="pico.png" usemap="#image-map"> | ||
|
||
<map name="image-map"> | ||
<area target="" alt="BOOTSEL" title="BOOTSEL" href="/reset_usb_boot" coords="319,97,11" shape="circle"> | ||
<area target="" alt="LED" title="LED" href="/toggle_led" coords="341,58,359,79" shape="rect"> | ||
</map> | ||
|
||
|
||
<br><br> | ||
You can click the LED and BOOTSEL button on the picture above. | ||
|
||
</center> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.