RetroBSD

2.11BSD operating system for microcontrollers
It is currently Sat Oct 19, 2019 12:14 am

All times are UTC




Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: Mon Dec 21, 2015 6:51 am 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
Hi everyone --

Is there a way to get LiteBSD on QEMU that also provides networking support? The example in the sergev/qemu wiki didn't work (or I did it wrong).

I'm asking because I wrote a simple package manager for LiteBSD (so that we can have our own version of the ports tree). It works perfectly for local packages. But I want to make sure the network fetching logic is correct before publishing.

_________________
@__briancallahan on Twitter


Top
 Profile  
 
PostPosted: Mon Dec 21, 2015 7:23 am 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
Hi Brian,

I've been thinking about porting opkg to LiteBSD. It looks pretty small and stable. People use it for OpenWrt.

The networking stuff should still work on QEMU. Tomorrow I'll double-check. At least it worked a few of weeks ago. You'll need a kernel configuration with en0 driver enabled, like MEB-II. Here is a startup script for QEMU with MEB-II configuration:
Code:
/usr/local/qemu-mips/bin/qemu-system-mipsel -M pic32mz-meb2 \
    -serial stdio \
    -serial mon:vc -nographic \
    -net nic \
    -net tap,ifname=tap0,script=no,downscript=no \
    -kernel /Users/vak/Project/BSD/LiteBSD/sys/compile/MEBII.pic32/vmunix.hex \
    -sd     /Users/vak/Project/BSD/LiteBSD/sdcard.img


Top
 Profile  
 
PostPosted: Mon Dec 21, 2015 3:30 pm 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
I get lots of:
--- pic32_uart_put_char(unit = 3) serial port not configured

and then qemu quits :-(

_________________
@__briancallahan on Twitter


Top
 Profile  
 
PostPosted: Mon Dec 21, 2015 5:46 pm 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
vak wrote:
I've been thinking about porting opkg to LiteBSD. It looks pretty small and stable. People use it for OpenWrt.

opkg is licensed GPLv2+, which is always a hard sell to BSD types like myself :D
My package manager is less robust but it does the trick in a very small ksh script. (and is well licensed) Plus I can lay down the groundwork to have a real ports system with this package manager. Not sure if I can do the same with opkg.
We can always add more stuff to it--and maybe it'll get people interested in doing dev work!

_________________
@__briancallahan on Twitter


Top
 Profile  
 
PostPosted: Tue Dec 22, 2015 6:06 am 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
ibara wrote:
I get lots of:
--- pic32_uart_put_char(unit = 3) serial port not configured

and then qemu quits :-(

Hmm... Serial port works for me:
Code:
$ ./qemu-litebsd-meb2.sh
WARNING: Image format was not specified for '/local/BSD/LiteBSD/sdcard.img' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.
Board: Microchip MEB-II
Processor: microAptivP
RAM size: 512 kbytes
Load file: '/local/BSD/LiteBSD/sys/compile/MEBII.pic32/vmunix.hex', 516308 bytes
Card0 image '/local/BSD/LiteBSD/sdcard.img', 205445 kbytes
Copyright (c) 1982, 1986, 1989, 1991, 1993
   The Regents of the University of California.  All rights reserved.

4.4BSD-Lite build 1 compiled 2015-12-21
    sergev@ubuntu-sergev:LiteBSD/sys/compile/MEBII.pic32
cpu: PIC32MZ2048ECH144 rev A4, 200 MHz
oscillator: system PLL div 1:6 mult x50
real mem = 512 kbytes
avail mem = 352 kbytes
using 18 buffers containing 73728 bytes of memory
spi1 at pins sdi=RD14/sdo=RB10/sck=RD1
spi2 at pins sdi=RD7/sdo=RG8/sck=RG6
spi4 at pins sdi=RG7/sdo=RB3/sck=RD10
Ethernet PHY not detected
uart1 at pins rx=RA14/tx=RA15, interrupts 112/113/114, console
sd0 at port spi2, pin cs=RB14
gpio0 at portA, pins ii---ii-iiiiiiii
gpio1 at portB, pins ioiiiiiiiiiiiiii
gpio2 at portC, pins iiii-------iiii-
gpio3 at portD, pins iiiiiii-ioiiiiii
gpio4 at portE, pins ------iiiiiiiiii
gpio5 at portF, pins --ii---i--iiiiii
gpio6 at portG, pins iiii--iiii----ii
gpio7 at portH, pins iiiiiiiiiiiiiiii
gpio8 at portJ, pins iiiiiiooiiiiiiii
gpio9 at portK, pins --------iiiiiiii
sd0: type I, size 205312 kbytes, speed 12 Mbit/sec
sd0a: partition type b7, sector 2, size 204800 kbytes
sd0b: partition type b8, sector 409602, size 32768 kbytes
sd0c: partition type b7, sector 475138, size 102400 kbytes
WARNING: preposterous clock chip time -- CHECK AND RESET THE DATE!

starting file system checks.
/dev/rsd0a: file system is clean; not checking
starting network
clearing /tmp
standard daemons: update.
Mon Dec 21 21:47:45 PST 2015


4.4BSD-Lite (bsd.net) (console)

login: root
Last login: Mon Dec 21 21:47:44 on console
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
        The Regents of the University of California.   All rights reserved.

4.4BSD-Lite UNIX #1: Fri Apr 01 00:00:00 PDT 1994

Welcome to 4.4BSD-Lite!

erase ^H, kill ^U, intr ^C status ^T
Don't login as root, use the su command.
# netstat -rn
Routing tables

Internet:
Destination      Gateway            Flags     Refs     Use  Interface
127.0.0.1        127.0.0.1          UH          0        0  lo0
# _

Ethernet port not recognized for some reason:
Code:
Ethernet PHY not detected

Seems like PHY autodetection is broken. I'll try to fix it tomorrow.

ibara wrote:
opkg is licensed GPLv2+, which is always a hard sell to BSD types like myself :D
I didn't think about it... GPL is not what we need. So you are right, we need to develop some replacement. Actually it's great you already have it working!

The first package in my mind is Dhrystone benchmark, to demonstrate Pito that MZ is faster that MX. :)

Thanks,
--Serge


Top
 Profile  
 
PostPosted: Tue Dec 22, 2015 11:00 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Quote:
to demonstrate Pito that MZ is faster that MX.

Just show me with rc4 and mandelbrot :) :P

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Tue Dec 29, 2015 10:50 pm 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
Hey Serge --

Have you had a chance to look at this?
Networking is now a must-have feature for me so I can get miscompiled code to the pcc maintainer.

_________________
@__briancallahan on Twitter


Top
 Profile  
 
PostPosted: Wed Dec 30, 2015 2:24 am 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
Hi Brian,
I'm still working on it - the Ethernet PHY detection.
I don't see any issues with serial port, though.
--Serge


Top
 Profile  
 
PostPosted: Wed Dec 30, 2015 2:57 am 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
Done!
The Ethernet detection is fixed. A register ADVRT in MII model was not writable. Now it should work as expected. Just use a default kernel configuration for MEB-II board.

Use the master branch of this repository: https://github.com/sergev/qemu

Best wishes,
--Serge


Top
 Profile  
 
PostPosted: Wed Dec 30, 2015 3:32 am 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
Thanks! That's a huge help.

_________________
@__briancallahan on Twitter


Top
 Profile  
 
PostPosted: Wed Dec 30, 2015 6:32 am 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
Now... for those of us who have been so spoiled as to have forgotten how to get online without dhclient... I set up everything according to the wiki, ran
Code:
sh /etc/netstart
on the QEMU machine, and... nothing :(

_________________
@__briancallahan on Twitter


Top
 Profile  
 
PostPosted: Wed Dec 30, 2015 7:51 am 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
When Ethernet port is detected at boot time, the network is started automatically by the /etc/rc script:
Quote:
en0 at interrupt 153, MAC address 52:54:00:12:34:56
en0: <SMSC LAN8740A> at address 0

uart1 at pins rx=RA14/tx=RA15, interrupts 112/113/114, console
sd0 at port spi2, pin cs=RB14
[...]
starting file system checks.
/dev/rsd0a: file system is clean; not checking
starting network
clearing /tmp
standard daemons: update inetd.
en0: link up, 100Mbps, full duplex
Tue Dec 29 19:11:23 PST 2015


4.4BSD-Lite (bsd.net) (console)

login: _

Script /etc/netstart configures the Ethernet port with fixed address 20.2.2.1:
Code:
if ifconfig en0 >/dev/null 2>&1; then
    ifconfig en0 inet 20.2.2.1
fi

On Linux side, the tap0 interface should be activated _before_ the QEMU start, with address 20.2.2.2:
Code:
sudo ifconfig tap0 20.2.2.2


In case you need an access from LiteBSD to the outer internet, you will have to use real IP addresses and add a default route:
Code:
# route add -net 0 20.2.2.2
add net 0: gateway 20.2.2.2

A routing on Linux side should be somehow enabled as well.


Top
 Profile  
 
PostPosted: Wed Dec 30, 2015 8:43 am 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
Thanks. Yes, I'll need outside Internet access. I'll sit down and figure it out.

_________________
@__briancallahan on Twitter


Top
 Profile  
 
PostPosted: Wed Dec 30, 2015 6:52 pm 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
I got QEMU to connect to an ftpd running on the host, which is good enough to transfer files so I'm happy :)

_________________
@__briancallahan on Twitter


Top
 Profile  
 
PostPosted: Wed Dec 30, 2015 8:09 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Congratulation! I have to kermit.. :)

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron




Powered by phpBB® Forum Software © phpBB Group

BSD Daemon used with permission