RetroBSD

2.11BSD operating system for microcontrollers
It is currently Tue Jul 14, 2020 10:02 am

All times are UTC




Post new topic Reply to topic  [ 192 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8 ... 10  Next
Author Message
PostPosted: Fri Dec 05, 2014 8:09 pm 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
Hi Alan,
EtchedPixels wrote:
Neat. Never thought I'd see someone bothering to bring up 4.4 again on anything!
It's like to disclose a secret knowledge of ancients, you know. :)

EtchedPixels wrote:
There is a distinction in types of MMU that is important. Many of the ARM and embedded MIPS cores have an MMU of sorts (however minimal). What they do not have is any kind of address remapping/translation.
This type of memory management is sometimes called MPU (memory protection unit). ARM Cortex M cores have MPU, which makes RetroBSD port possible. MIPS architecture imposes a separation of kernel vs user memory access privileges, which is enough for 2BSD kernel.

EtchedPixels wrote:
4BSD also needs restartable instructions - that is you must be able by some means (fair or foul - often quite foul) to restart the instruction that trapped with a page translation exception. 2BSD doesn't need this - and the PDP11 can't in fact do it.
On MIPS, all instructions which can cause exception are restartable. I believe the same is true for ARM as well.

EtchedPixels wrote:
On the NetBSD/OpenBSD side nobody afaik has ever tackled adding MMUless support, although its certainly possible.
Well... Not so easy. It would require to essentially remove all the VM stuff from the kernel and turn it back into swapping-only system. Currently most of the kernel relies on the ability to (1) remap data pages freely and (2) page out/in the kernel address space.

EtchedPixels wrote:
4.4lite while 'cute' is a bit pointless given NetBSD is faster, cleaner and more importantly isn't trivially remotely rootable with hundreds of known documented holes.
NetBSD is great, I agree, especially highly efficient UVM implementation of virtual memory. Except that the minimal RAM requirement is 16 Mbytes. Nothing even close to 1/2 Mbyte of pic32mz.

The only way I see is to start from bare 4.4BSD sourcebase and develop it in NetBSD/OpenBSD direction, keeping it small and efficient.

--Serge


Top
 Profile  
 
PostPosted: Fri Dec 05, 2014 8:16 pm 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
Hi Wiz,
wiz wrote:
( The previous chip had access holes from user to kernel space. )
It was not the chip which had access holes. :)
I've added a couple of nonstandard system calls especially for you, so you could access kernel data and hardware registers from user space, for your experiments with custom debugger/programmer.

--Serge


Top
 Profile  
 
PostPosted: Fri Dec 05, 2014 8:40 pm 
Contributor

Joined: Mon Nov 12, 2012 1:34 pm
Posts: 1092
Hi Serge,

It wasn't those functions I was talking about.

I found that by writing assembly code I could read and write kernel RAM from user space. I don't remember if I could execute it. IIRC, I think not.

But I was alarmed at being able read and write kernel space since a deviant application could do serious things to the kernel in that way.

Perhaps there are some flags or interrupts that could be set? I don't know that much about that chip? So perhaps I spoke too quickly?

Anyways, the MZ is the chip of real interest. And the MMU functions regards huge applications.

Your telnet application is MOST impressive.

Guess I gotta get it up and running soon :).

Not sure what to make of the 'lots of bugs' comment. But for my applications this doesn't seem like much of a problem?

Mounting a remote filesystem would certainly be useful.

Wiz


Top
 Profile  
 
PostPosted: Fri Dec 05, 2014 9:00 pm 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
wiz wrote:
It wasn't those functions I was talking about.

I found that by writing assembly code I could read and write kernel RAM from user space. I don't remember if I could execute it. IIRC, I think not.
Can you please provide an example of your code? I'm pretty sure it's not possible on pic32mx. Only user segment 0x00000000-7fffffff is addressable from user mode. Part of internal RAM is mapped to 0x7f008000-0x7f01ffff, i.e. higher 96kbytes. The boundary between kernel and user RAM is defined by BMXDUPBA register. Any user attempt to access non-mapped part of RAM causes an exception. See Table 3-2 in PIC32MX Family Reference Manual.

wiz wrote:
Anyways, the MZ is the chip of real interest. And the MMU functions regards huge applications.
Sure, it's possible to run "huge" applications, though with poor performance.

wiz wrote:
Your telnet application is MOST impressive.

Mounting a remote filesystem would certainly be useful.
It's actually a standard Unix telnet application. Code for mounting network filesystems is present in the kernel as well. I've not tried it, as I don't have drivers for any network interface yet.

--Serge


Top
 Profile  
 
PostPosted: Sat Dec 06, 2014 1:02 pm 

Joined: Mon Nov 24, 2014 6:12 am
Posts: 13
Location: Australia
EtchedPixels wrote:
4.4lite while 'cute' is a bit pointless given NetBSD is faster, cleaner and more importantly isn't trivially remotely rootable with hundreds of known documented holes.

Serge wrote:
NetBSD is great, I agree, especially highly efficient UVM implementation of virtual memory. Except that the minimal RAM requirement is 16 Mbytes. Nothing even close to 1/2 Mbyte of pic32mz.

The only way I see is to start from bare 4.4BSD sourcebase and develop it in NetBSD/OpenBSD direction, keeping it small and efficient.


Small and efficient.. I think this is the correct approach.

Pretty amazing to think it's even possible to run a "real" operating system on a pic.. Just having the ability to have programs load from SD card and execute is incredibly valuable, not to mention data logging with the storage capacity of sd cards today, and anyway who needs big executables, unix philosophy is small executables, like building blocks.. but everyone already knows this.

What is really exciting here is the networking potential..

Pretty amazing rate of progress in just a week or so.. I'd like to help, maybe a bit of code, and some testing?

Ray


Top
 Profile  
 
PostPosted: Sat Dec 06, 2014 8:29 pm 
Contributor

Joined: Mon Nov 12, 2012 1:34 pm
Posts: 1092
Hi Serge and RayG and all,

Serge - It will take a day or two to resurrect that stuff. It was peeked and poked assembly code IIRC. Maybe caused by regs being set to bad values by me, but I don't think so. Anyways I will try to recreate it.

Ray - I second your excitement. Can we do some kernel loadable modules so that many drivers can be written and tested easily by you and me and others. I have gotten this working on the MX, but as noted 4.4 has real networking.

The ability to write huge programs really excites me. There are many cases where it is loads easier to just make it huge rather than worrying about paging, etc.

Also the ability to have many programs 'running' at once. Some 'locked' into RAM so they can handle faster interrupts, etc.

Necessary fast stuff can also be in a kernel loadable module or some such hack.

Most exciting :).

Great job Serge - Mr. LiteBSD !!!!!

Wiz


Top
 Profile  
 
PostPosted: Sat Dec 06, 2014 10:05 pm 
Committer
User avatar

Joined: Thu Oct 11, 2012 8:45 am
Posts: 1801
Location: Room 217, Floor 8, Arm 8, Wheel S7, Mars Base Alpha 3
Talking of huge programs - I got nvi half working earlier. It would load and operate, but for some reason wouldn't load or save a file. I have since got sidetracked solving a bug in mktemp(), but I may get back to it later on :)

... later on ...

It seems that it may be something to do with command line arguments. I can load and save text with :r ... and :w ... but I can't use "vi /path/to/file".

Also it just caused a lockup while moving the cursor. SD card LED was on solid at the time, and the SD needed ejecting to get it working again after a reboot. There's definitely something up with the SD driver.

_________________
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".


Top
 Profile  
 
PostPosted: Sat Dec 06, 2014 11:42 pm 
Committer
User avatar

Joined: Thu Oct 11, 2012 8:45 am
Posts: 1801
Location: Room 217, Floor 8, Arm 8, Wheel S7, Mars Base Alpha 3
I now have kermit working (kind of) as well.

I managed to use it to transfer a file to my WiFire. Transferring back the other way though didn't work. There seems to be something not quite right with serial comms at the moment causing packet corruption.

_________________
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".


Top
 Profile  
 
PostPosted: Sun Dec 07, 2014 1:48 am 

Joined: Sun Dec 07, 2014 1:47 am
Posts: 22
majenko wrote:
I now have kermit working (kind of) as well.

I managed to use it to transfer a file to my WiFire. Transferring back the other way though didn't work. There seems to be something not quite right with serial comms at the moment causing packet corruption.


Have you tried with a lower baud rate?


Top
 Profile  
 
PostPosted: Sun Dec 07, 2014 5:05 am 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
majenko wrote:
I managed to use it to transfer a file to my WiFire. Transferring back the other way though didn't work. There seems to be something not quite right with serial comms at the moment causing packet corruption.
Recently I've reduced the size of uart ring buffers to 256 bytes. Not sure whether it helps, but it makes sense to try to increase it to, say, 1024. See clalloc() calls in uartopen() function, file sys/mips/dev/uart.c.


Top
 Profile  
 
PostPosted: Sun Dec 07, 2014 11:45 am 
Committer
User avatar

Joined: Thu Oct 11, 2012 8:45 am
Posts: 1801
Location: Room 217, Floor 8, Arm 8, Wheel S7, Mars Base Alpha 3
Nope, no different. I've even tried different send/receive packet sizes in kermit, to no avail.

I have seen it corrupting when pasting in text as well - missing out characters, etc. My guess is the lack of any flow control.

Code:
RECEIVE- or GET-class command failed.
 Packets received: 13
 Damaged packets: 0
 Timeouts: 8
 Packet length: 32
 Transfer canceled by sender.
 Sender's message: "Too many retries."

_________________
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".


Top
 Profile  
 
PostPosted: Mon Dec 08, 2014 10:44 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
I wonder if the rz sz would work there?

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Tue Dec 09, 2014 7:35 pm 

Joined: Sun Dec 07, 2014 1:47 am
Posts: 22
Largely-related...re there pre-made images by chance? I've had difficulty building...perhaps I'm just forgetting a step?

I'd love to take a look at this and see what communication stuff I can come up with.


Top
 Profile  
 
PostPosted: Tue Dec 09, 2014 8:35 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
chipKIT Wi-Fire:

http://vak.ru/pub/unix/4.4bsd-pic32mz-binaries-0.1.zip

http://vak.ru/pub/unix/4.4bsd-pic32mz-sources-0.1.zip

// flash kernel into pic32MZ
sudo pic32prog -d /dev/ttyUSB0 vmunix.hex

// copy image to sdcard "sdc", could be different on your linux box
sudo dd bs=32k if=sdcard.img of=/dev/sdc

console 115k2

boots into multi-user mode, press "1" during boot for single

https://code.google.com/p/pic32prog/wiki/README

No warranties of any kind :twisted:

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Tue Dec 09, 2014 10:39 pm 
Committer
User avatar

Joined: Thu Oct 11, 2012 8:45 am
Posts: 1801
Location: Room 217, Floor 8, Arm 8, Wheel S7, Mars Base Alpha 3
In other news, I have found there is a (as yet unidentified) bug in bcopy(), which is where my problems with vi have been coming from. I've replaced it internally in vi, and it now works like a charm. vipw is now usable.

Also, I have implemented RCNG from FreeBSD to replace the existing /etc/rc system. It's a bit sluggish, but allows for a /etc/rc.conf file, and /etc/rc.d/* files for starting / stopping services properly. Given the lack of speed, I may pop that into another branch instead of master.
Code:
Copyright (c) 1982, 1986, 1989, 1991, 1993
   The Regents of the University of California.  All rights reserved.

4.4BSD-Lite build 1 compiled 2014-12-09
    matt@dell:LiteBSD/sys/compile/WIFIRE.pic32
cpu: PIC32MZ2048ECG100 rev A4, 200 MHz
oscillator: system PLL div 1:6 mult x50
cache: 16/4 kbytes
real mem = 512 kbytes
avail mem = 320 kbytes
using 18 buffers containing 73728 bytes of memory
spi1 at pins sdi=D14/sdo=C1/sck=D1
spi2 at pins sdi=F0/sdo=D11/sck=G6
spi3 at pins sdi=B10/sdo=C4/sck=B14
spi4 at pins sdi=F5/sdo=G0/sck=D10
uart1 at pins rx=F1/tx=D15, interrupts 112/113/114
uart4 at pins rx=F2/tx=F8, interrupts 170/171/172, console
sd0 at port spi3, pin cs=C3
sd0: type II, size 1934336 kbytes, speed 20 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
bpf: lo0 attached
WARNING: preposterous clock chip time -- CHECK AND RESET THE DATE!

Starting file system checks.
/dev/rsd0a: file system is clean; not checking
Mounting local filesystems...done.
Starting swap...done.
Setting hostname: bsd44.majenko.co.uk.
Starting Network: lo0.
lo0: flags=8009<UP,LOOPBACK,MULTICAST>
        inet 127.0.0.1 netmask 0xff000000
Building device database...done.

Tue Dec  9 14:26:53 PST 2014


4.4BSD-Lite (bsd44.majenko.co.uk) (tty4)

login: 

_________________
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".


Top
 Profile  
 
PostPosted: Wed Dec 10, 2014 12:17 am 

Joined: Sun Dec 07, 2014 1:47 am
Posts: 22
Pito wrote:
chipKIT Wi-Fire:

http://vak.ru/pub/unix/4.4bsd-pic32mz-binaries-0.1.zip

http://vak.ru/pub/unix/4.4bsd-pic32mz-sources-0.1.zip

// flash kernel into pic32MZ
sudo pic32prog -d /dev/ttyUSB0 vmunix.hex

// copy image to sdcard "sdc", could be different on your linux box
sudo dd bs=32k if=sdcard.img of=/dev/sdc

console 115k2

boots into multi-user mode, press "1" during boot for single


Sweet! Booted fine!

Now I just gotta get a build env. working!


Top
 Profile  
 
PostPosted: Wed Dec 10, 2014 12:46 am 

Joined: Sun Dec 07, 2014 1:47 am
Posts: 22
gewtnet wrote:
Pito wrote:
chipKIT Wi-Fire:

http://vak.ru/pub/unix/4.4bsd-pic32mz-binaries-0.1.zip

http://vak.ru/pub/unix/4.4bsd-pic32mz-sources-0.1.zip

// flash kernel into pic32MZ
sudo pic32prog -d /dev/ttyUSB0 vmunix.hex

// copy image to sdcard "sdc", could be different on your linux box
sudo dd bs=32k if=sdcard.img of=/dev/sdc

console 115k2

boots into multi-user mode, press "1" during boot for single


Sweet! Booted fine!

Now I just gotta get a build env. working!


Getting stumped up at:
Code:
csmelosky@linux-builder:~/LiteBSD$ export BSDSRC=$HOME/LiteBSD
csmelosky@linux-builder:~/LiteBSD$ export MIPS_GCC_ROOT=/usr/local/mips-2014.05
csmelosky@linux-builder:~/LiteBSD$ export DESTDIR=$BSDSRC/DESTDIR
csmelosky@linux-builder:~/LiteBSD$ export MAKESYSPATH=$BSDSRC/share/mk-pic32
csmelosky@linux-builder:~/LiteBSD$ bmake kernel
bmake -Cusr.sbin/config
gcc  -Werror -c config.c
bmake[1]: exec(gcc) failed (No such file or directory)
*** Error code 1


Can't build any of it as the environment vars aren't being respected, or are the build docs missing something important?

Code:
csmelosky@linux-builder:~/4.4bsd-pic32mz-sources-0.1$ ls /usr/local/mips-2014.05
bin  i686-pc-linux-gnu  lib  libexec  mips-sde-elf  share


Man pages are nonfunctional despite being present, I want to take a crack and generating an install more suited to my environment.


Top
 Profile  
 
PostPosted: Wed Dec 10, 2014 1:02 am 
Committer
User avatar

Joined: Thu Oct 11, 2012 8:45 am
Posts: 1801
Location: Room 217, Floor 8, Arm 8, Wheel S7, Mars Base Alpha 3
Looks like you don't have GCC installed for building the tools needed to build bsd. Install the build-essential (I think it is) package.

_________________
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".


Top
 Profile  
 
PostPosted: Wed Dec 10, 2014 2:09 am 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
majenko wrote:
In other news, I have found there is a (as yet unidentified) bug in bcopy(), which is where my problems with vi have been coming from.

I created a simple testbench for bcopy(), which data of size from 0 to 36 bytes, with all possible variations of unalignments for source and destination buffers. Seems like bcopy() itself is fine. I tested both LiteBSD bcopy implementation (by Ralph Campbell, Berkeley) and RetroBSD variant (from Carnegie Mellon University). Both work strictly according to the spec. The timing is diferent, though. See charts below.
Attachment:
bcopy-aligned.png
bcopy-aligned.png [ 21.28 KiB | Viewed 15123 times ]

Attachment:
bcopy-unaligned.png
bcopy-unaligned.png [ 21.52 KiB | Viewed 15123 times ]

RetroBSD version is slightly more efficient on aligned transfers multiple of 4 words.

Sources:
https://github.com/sergev/LiteBSD/blob/ ... ng/bcopy.s
https://github.com/RetroBSD/retrobsd/bl ... ng/bcopy.S


Top
 Profile  
 
PostPosted: Wed Dec 10, 2014 2:22 am 

Joined: Sun Dec 07, 2014 1:47 am
Posts: 22
majenko wrote:
Looks like you don't have GCC installed for building the tools needed to build bsd. Install the build-essential (I think it is) package.


Won't that install an AMD64 compiler, though? It SHOULD be using the MIPS compiler, correct?

EDIT: I grasp the build environment now. D'oh! `config` needs to know how to generate a config so of COURSE that needs a native compiler.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 192 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8 ... 10  Next

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