RetroBSD

2.11BSD operating system for microcontrollers
It is currently Sun Jun 17, 2018 11:35 pm

All times are UTC




Post new topic Reply to topic  [ 106 posts ]  Go to page 1, 2, 3, 4, 5, 6  Next
Author Message
PostPosted: Sun Oct 20, 2013 4:13 am 
Contributor
User avatar

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

Here's emg(1), or Ersatz Mg, a very tiny Emacs-like text editor. It clocks in a bit smaller than VIrus (emg is about 58K).

This is the result of trying to port Mg and/or Ersatz Emacs to RetroBSD. Neither worked but taking bits from both to create a single editor resulted in emg. I've tested this on the virtualmips emulator; I'll be getting a MAX32 board soon and will test it there as well, though I can't see why it wouldn't just work.

Attached here is a tarball ready to be dropped in the tree. You should take a look at the Makefile and set -DFORCE_COLS and -DFORCE_ROWS to the size of your terminal. emg can be run as small as col=10 and rows=3.

The extra CFLAGS and LDFLAGS shaved off about 400 bytes, which I'm happy to get back.

Below is a Makefile hookup patch.

emg is public domain.

You can also find the source code here:
https://github.com/ibara/emg

Thanks!

~Brian

Code:
Index: Makefile
===================================================================
--- Makefile   (revision 892)
+++ Makefile   (working copy)
@@ -76,7 +76,8 @@
                   $(wildcard include/smallc/*.h) \
                   $(wildcard include/smallc/sys/*.h) \
                   $(wildcard include/arpa/*.h)
-SHARE_FILES   = share/re.help share/example/Makefile \
+SHARE_FILES   = share/re.help share/emg.keys \
+                  share/example/Makefile \
                   share/example/ashello.S share/example/chello.c \
                   share/example/blkjack.bas share/example/hilow.bas \
                   share/example/stars.bas share/example/prime.scm \
@@ -176,6 +177,7 @@
       rm -f sys/pic32/*/unix.hex bin/* sbin/* games/[a-k]* games/[m-z]* libexec/* share/man/cat*/*
       rm -f games/lib/adventure.dat
       rm -f games/lib/cfscores
+      rm -f share/emg.keys
       rm -f share/re.help
       rm -f share/misc/more.help
       rm -f etc/termcap etc/remote etc/phones
Index: src/cmd/Makefile
===================================================================
--- src/cmd/Makefile   (revision 892)
+++ src/cmd/Makefile   (working copy)
@@ -11,7 +11,7 @@
 # Programs that live in subdirectories, and have makefiles of their own.
 # /bin
 SUBDIR      = adb adc-demo ar as awk basic cc chflags chpass \
-                  cpp dc diff env fdisk find forth fstat glcdtest hostname \
+                  cpp dc diff emg env fdisk find forth fstat glcdtest hostname \
                   id la lcc lcpp ld ls login make man med \
                   more nm passwd picoc portio printf pwm \
                   rdprof ranlib re renice retroforth scm setty sl \


Attachments:
File comment: emg 1.0, with Makefile for RetroBSD
emg.tgz [45.55 KiB]
Downloaded 314 times

_________________
@__briancallahan on Twitter
Top
 Profile  
 
PostPosted: Thu Oct 24, 2013 5:34 am 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
emg 1.1 has been released; mostly code cleanups.
Now builds warning free with -Wall, so -Wall and -Werror are now set.
Setting -mips16 results in a binary of 46K (untested; I will be getting my MAX32 board this weekend while I'm at vBSDcon).

Source code at the Github link in the OP, or grab a tarball at http://devio.us/~bcallah/emg/

~Brian

_________________
@__briancallahan on Twitter


Top
 Profile  
 
PostPosted: Thu Oct 24, 2013 7:12 pm 
Contributor

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

I wonder if a hex mode, like hexedit would be easy?

It would be handy sometimes.

Wiz


Top
 Profile  
 
PostPosted: Fri Oct 25, 2013 5:13 am 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
Hex editors aren't traditional in these small C Emacs clones. That's just bloat for bloat's sake.
A better solution would be to port hexedit itself. If there's interest, I can look at doing so when I return from vBSDcon.

~Brian

_________________
@__briancallahan on Twitter


Top
 Profile  
 
PostPosted: Fri Oct 25, 2013 5:09 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
I've seen your MIPS on OpenBSD slides - what I am missing there is the 4.4BSD on the PIC32MZ..
:)

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Sun Oct 27, 2013 1:56 pm 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
If you could get a PIC32 with enough RAM/storage to hold OpenBSD, the infrastructure could probably be whipped up relatively easily :)

Btw, the audio that goes along with those slides is here: http://www.nycbug.org/?action=event&do= ... 0334#10334

_________________
@__briancallahan on Twitter


Top
 Profile  
 
PostPosted: Sun Oct 27, 2013 6:53 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
How much ram do you need?
PIC32MZ (512kB internal ram) can address 2MB of external ram in 100pin package and 32MB external ram in 144pin package.

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Mon Oct 28, 2013 5:27 pm 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
32MB might be enough to physically do a build (with a generous helping of swap) but the result would be painful in use since you'd be swapping everything.

_________________
@__briancallahan on Twitter


Top
 Profile  
 
PostPosted: Tue Oct 29, 2013 7:10 am 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
By the way, now that I have a MAX32 board I was finally able to test emg on real hardware. It works well with CFLAGS+=-mips16

_________________
@__briancallahan on Twitter


Top
 Profile  
 
PostPosted: Tue Oct 29, 2013 8:35 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
I am unsure about the 32MB. There are two 16MB slots of memory in the memory map for mappable memory - one for parallel SRAM, and one for SQI serial SRAM. The data sheet for the parallel interface talks about memory mapping, and details the registers for it. The SQI datasheet makes no mention at all of memory mapping and I can see no registers pertaining to it.

I don't yet know which document to believe - the memory organisation data sheet or the SQI data sheet.

_________________
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: Tue Oct 29, 2013 9:20 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
There are 24 addresses (0..EBIA23) with 144pin package. That is 16M words. 1 word =16bit (0..EBID15). There are 4 chip selects as well. The parameter "MEMSIZE <4:0>: Select the memory chip select size x-bit (1)" maxes at "01001 = 16 MB"..
So - how to combine that info? (based on the Chinese pdf).
PS: a naive approach could lead to 4x16Mx2 external memory size..

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Tue Oct 29, 2013 5:41 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 have the official Microchip documentation, not some Chinese knockoff ;)

There is 64MB of memory space allocated to EBI mapping. That is between physical addresses 0x20000000 and 0x23FFFFFF. The largest mappable device per chip select is 16MB. There are 4 chip selects, each of which can be mapped to a start location within that space with its own device size, so a maximum of 64MB as 4x16MB devices can be directly supported. With a bit of extra glue logic it should be possible to convert the 4 chip selects into a single chip select and a 2-bit high-order address signal to allow a single 64MB device to be mapped into the address in 4x16MB chunks.

The memory is mapped in the "kseg2" section, so the linker script has to be set up to make that memory available, and variables and data sections have to be mapped in to it for it to be of any use.

If the memory organization document is to be believed there is a similar sized chunk of memory for SQI RAM, but the SQI documentation is silent about it.

So there is theoretically 128MB of extra RAM space direcly available (64MB fast access, 64MB slow access), or more if you want to do manual paging, which is something the RetroBSD kernel could possibly do for us (one page for user memory, one page for kernel memory - the kernel switches in its memory space to access internal buffers, like large network buffers, video framebuffers, etc, aoc moves data around into "common" internal shared memory, then switches back to user RAM to return execution to a running thread).

_________________
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: Tue Oct 29, 2013 6:11 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
The only issue I see is the srams chips are small volumes only. I've got psrams (ISSI 16x4M, 8MB) - today the biggest available chip. There is a bigger one from micron (16x8M), but end of production. There are smaller (and faster - 10ns) chips - 8x2M, 16x1M, but, frankly, 64MB/128MB of sram are tons of silicon today..
:shock:

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Tue Oct 29, 2013 6:23 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
The biggest SRAM that Farnell stock is 64Mbit (4Mx16), and that's in 48FBGA format. To fill the memory space with those would require a little bit of glue logic to bolt them together into pairs, and would take 8 chips, costing a total of about £250+.

Is it really worth it, financially...?

_________________
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: Tue Oct 29, 2013 6:59 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
The 4Mx16 (8MB) ISSI sram (BGA48) costs 3.73Euro (3.15 in your currency) a piece in 10pcs quantity ( http://uk.mouser.com/Search/ProductDeta ... 1Tl12BYg== ).
So not so bad. You need 2pcs for 8MB swap and 8MB fs (for example). No glue logic needed. That is feasible and cheap..
64MB will cost us 30Euro (excl. VAT).
That is the big pain with none existing sdram controller with pic32mz. That might kill the chip btw..

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Tue Oct 29, 2013 7:09 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
Nice. Farnell hasn't heard of PSRAM yet...

You wouldn't use it as swap and FS though, you'd use it as real, active memory. Ideally we'd have some kind of active kernel-based memory management and protection system in place so multiple processes can be in RAM at once without swapping.

_________________
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: Tue Oct 29, 2013 7:24 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Maybe we shall continue in the 32MZboard topic - there are some designs thoughts with the 48bga chip done already. I pled for a linear 16MByte space (banked as the 100pin version can do 2MB only) with 2 chips which may fit there instead the dram we have on the 32MXboard. Jaromir says it is doable - we will see, however..
viewtopic.php?f=3&t=5107&p=6681#p6681
:)

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Wed Oct 30, 2013 4:25 am 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
Back in emg land... :D

I discovered that ^s may not work with the OpenBSD cu(1)/tip(1) implementation. A simple solution is to use picocom (comms/picocom in ports) instead as the calling program.

_________________
@__briancallahan on Twitter


Top
 Profile  
 
PostPosted: Wed Oct 30, 2013 9:21 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
^S and ^Q are part of the XON/XOFF protocol - ^S for stop, and ^Q for restart. It is likely that cu/tip is honouring that protocol. I find using Konsole if I am not actively using something interactive like minicom within it handles ^S and ^Q as pause and restart.

_________________
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 Oct 30, 2013 6:32 pm 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
majenko wrote:
^S and ^Q are part of the XON/XOFF protocol

Right... it's been a while since I had to care about serial connections (and use something emacs-y as I mostly use vi). Maybe it's worth changing the keybindings then.

_________________
@__briancallahan on Twitter


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 106 posts ]  Go to page 1, 2, 3, 4, 5, 6  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:




Powered by phpBB® Forum Software © phpBB Group

BSD Daemon used with permission