Skip to content

Commit 3230344

Browse files
committed
Playing around with lwip and qemu
1 parent 9a517e2 commit 3230344

File tree

10 files changed

+2539
-15
lines changed

10 files changed

+2539
-15
lines changed

Diff for: .vscode/c_cpp_properties.json

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Mac",
5+
"includePath": ["/usr/include"],
6+
"browse" : {
7+
"limitSymbolsToIncludedHeaders" : true,
8+
"databaseFilename" : ""
9+
}
10+
},
11+
{
12+
"name": "Linux",
13+
"includePath": ["/usr/include",
14+
"/home/olas/esp/esp-idf/components/freertos/include",
15+
"/home/olas/esp/esp-idf/components/nvs_flash/include/",
16+
"/home/olas/esp/esp-idf/components/esp32/include/",
17+
"/home/olas/esp/esp-idf/components/log/include/",
18+
"/home/olas/esp/esp-idf/components/driver/include/",
19+
"/home/olas/esp/esp-idf/components/tcpip_adapter/include",
20+
"/home/olas/esp/esp-idf/components/tcpip_adapter/include",
21+
"/home/olas/esp/esp-idf/components/lwip/include",
22+
"/home/olas/esp/esp-idf/components/lwip/include/lwip/port",
23+
"/home/olas/esp/esp-idf/components/lwip/include/lwip",
24+
"/home/olas/esp/esp-idf/",
25+
"/home/olas/esp/esp-idf/"
26+
],
27+
"browse" : {
28+
"limitSymbolsToIncludedHeaders" : true,
29+
"databaseFilename" : ""
30+
}
31+
},
32+
{
33+
"name": "Win32",
34+
"includePath": ["c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include"],
35+
"browse" : {
36+
"limitSymbolsToIncludedHeaders" : true,
37+
"databaseFilename" : ""
38+
}
39+
}
40+
]
41+
}

Diff for: .vscode/tasks.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"version": "0.1.0",
3+
"command": "make",
4+
"isShellCommand": true,
5+
"tasks": [
6+
{
7+
"taskName": "Makefile",
8+
// Make this the default build command.
9+
"isBuildCommand": true,
10+
// Show the output window only if unrecognized errors occur.
11+
"showOutput": "always",
12+
// No args
13+
"args": ["all"],
14+
// Use the standard less compilation problem matcher.
15+
"problemMatcher": {
16+
"owner": "cpp",
17+
"fileLocation": ["relative", "${workspaceRoot}"],
18+
"pattern": {
19+
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
20+
"file": 1,
21+
"line": 2,
22+
"column": 3,
23+
"severity": 4,
24+
"message": 5
25+
}
26+
}
27+
}
28+
]
29+
}

Diff for: BOOT.md

+8
Original file line numberDiff line numberDiff line change
@@ -2023,3 +2023,11 @@ io read 42010 SPI_CMD_REG1 3ff42010=0
20232023
20242024
```
20252025

2026+
#Precise timer ccount, depends of frequency..
2027+
```
2028+
Rom function
2029+
2030+
xthal_get_ccount = 0x4000c050
2031+
2032+
2033+
```

Diff for: README.md

+14-7
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,9 @@ rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
274274
flash read err, 1000
275275
Falling back to built-in command interpreter.
276276
```
277+
The command interpreter is Basic, Here you can read about it
278+
http://hackaday.com/2016/10/27/basic-interpreter-hidden-in-esp32-silicon/
279+
277280
##What is the problem with this code
278281
Some i/o register name mapping in esp32.cis probably wrong. The values returned are also many times wrong.
279282
I did this mapping very quickly with grep to get a better understanding of what the rom was doing.
@@ -393,11 +396,15 @@ To use it properly you must increase the num_regs = 104 to i.e. 211 in core-esp3
393396
As I am not alwas sure of what I am doing, I would recomend this version of the software. Currently it is not yet finnished (11//11) but will most certainly be better if Max finds the time to work on it.
394397

395398
#A better version of qemu with esp32 exists here,
396-
git clone https://github.com/OSLL/qemu-xtensa
397-
cd qemu-xtensa
398-
git checkout xtensa-esp32
399-
git submodule update --init dtc
400-
cd ..
401-
mkdir build-qemu-xtensa
402-
../qemu-xtensa/configure --disable-werror --prefix=`pwd`/root --target-list=xtensa-softmmu
399+
git clone https://github.com/OSLL/qemu-xtensa
400+
cd qemu-xtensa
401+
git checkout xtensa-esp32
402+
git submodule update --init dtc
403+
Add /hw/xtensa/esp32.c as described eariler in this doc
404+
Edit this row
405+
serial_hds[0] = qemu_chr_new("serial0", "null",NULL);
406+
cd ..
407+
mkdir build-qemu-xtensa
408+
cd build-qemu-xtensa
409+
../qemu-xtensa/configure --disable-werror --prefix=`pwd`/root --target-list=xtensa-softmmu
403410

Diff for: main/emulwIP.c

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*
2+
*********************************************************************************************************
3+
* lwIP TCP/IP Stack
4+
* port for uC/OS-II RTOS on TIC6711 DSK
5+
*
6+
* File : tcp_ip.c
7+
* By : ZengMing @ DEP,Tsinghua University,Beijing,China
8+
*********************************************************************************************************
9+
*/
10+
#include <stdio.h>
11+
#include <string.h>
12+
#include <ctype.h>
13+
#include <stdlib.h>
14+
#include "lwip/opt.h"
15+
#include "lwip/def.h"
16+
#include "lwip/mem.h"
17+
#include "lwip/pbuf.h"
18+
#include "lwip/sys.h"
19+
#include "lwip/timers.h"
20+
#include <lwip/stats.h>
21+
#include "lwip/netif.h"
22+
#include "netif/etharp.h"
23+
#include "lwip/tcpip.h"
24+
25+
26+
#include "port/arch/sys_arch.h"
27+
// -- Generic network interface --
28+
29+
extern err_t ne2k_init(struct netif *netif);
30+
31+
32+
33+
struct netif ne2kif_if;
34+
//struct netif loop_if;
35+
36+
void ethernet_hardreset(void); //These reset codes are built for C6711 DSP
37+
void tcpip_init_done_ok(void * arg);
38+
39+
40+
void Task_lwip_init(void * pParam)
41+
{
42+
ip4_addr_t ipaddr, netmask, gw;
43+
//sys_sem_t sem;
44+
45+
ethernet_hardreset();//hard reset of EthernetDaughterCard
46+
47+
#if LWIP_STATS
48+
stats_init();
49+
#endif
50+
51+
// initial lwIP stack
52+
sys_init();
53+
mem_init();
54+
memp_init();
55+
pbuf_init();
56+
netif_init();
57+
58+
printf("TCP/IP initializing...\n");
59+
//sem = sys_sem_new(0);
60+
// OLAS tcpip_init(tcpip_init_done_ok, &sem);
61+
//sys_sem_wait(sem);
62+
//sys_sem_free(sem);
63+
printf("TCP/IP initialized.\n");
64+
65+
//add loop interface //set local loop-interface 127.0.0.1
66+
/*
67+
IP4_ADDR(&gw, 127,0,0,1);
68+
IP4_ADDR(&ipaddr, 127,0,0,1);
69+
IP4_ADDR(&netmask, 255,0,0,0);
70+
netif_add(&loop_if, &ipaddr, &netmask, &gw, NULL, loopif_init,
71+
tcpip_input);*/
72+
73+
//add ne2k interface
74+
IP4_ADDR(&gw, 192,168,1,1);
75+
IP4_ADDR(&ipaddr, 192,168,1,100);
76+
IP4_ADDR(&netmask, 255,255,255,0);
77+
78+
netif_add(&ne2kif_if, &ipaddr, &netmask, &gw, NULL, ne2k_init, tcpip_input);
79+
netif_set_default(&ne2kif_if);
80+
netif_set_up(&ne2kif_if); // new step from lwip 1.0.0
81+
82+
printf("Applications started.\n");
83+
84+
//---------------------------------------------------------------------
85+
//All thread(task) of lwIP must have their PRI between 10 and 14.
86+
//------------------------------------------------------------
87+
//sys_thread_new(httpd_init, (void*)"httpd",10);
88+
//httpd_init();
89+
//---------------------------------------------------------------------
90+
91+
92+
//DSP_C6x_TimerInit(); // Timer interrupt enabled
93+
// Ethernet interrupt
94+
//DSP_C6x_Int4Init(); // Int4(Ethernet Chip int) enabled
95+
96+
97+
/* Block for ever. */
98+
//sem = sys_sem_new(0);
99+
//sys_sem_wait(sem);
100+
printf("Finished\n");
101+
}
102+
103+
//---------------------------------------------------------
104+
void tcpip_init_done_ok(void * arg)
105+
{
106+
sys_sem_t *sem;
107+
sem = arg;
108+
sys_sem_signal(*sem);
109+
}
110+
111+
112+
/*-----------------------------------------------------------*/
113+
/* This function do the hard reset of EthernetDaughterCard *
114+
* through the DaughterBoardControl0 signal in DB-IF */
115+
/*-----------------------------------------------------------*/
116+
void ethernet_hardreset(void) //These reset codes are built for C6711 DSK
117+
{
118+
119+
}
120+
121+
122+

0 commit comments

Comments
 (0)