Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)

Liste des GroupesRevenir à cl forth 
Sujet : Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)
De : antispam (at) *nospam* fricas.org (Waldek Hebisch)
Groupes : comp.lang.forth
Date : 26. Oct 2024, 02:31:58
Autres entêtes
Organisation : To protect and to server
Message-ID : <vfhgqc$3sajh$1@paganini.bofh.team>
References : 1 2 3 4 5 6
User-Agent : tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.0-9-amd64 (x86_64))
Waldek Hebisch <antispam@fricas.org> wrote:
albert@spenarnc.xs4all.nl wrote:
In article <vf5a40$2fkdi$1@paganini.bofh.team>,
Waldek Hebisch <antispam@fricas.org> wrote:
<SNIP>
>
RISCV ciforth beta 2023Mar30
MMAP-IO
OK
HEX
OK
VMA-IO @ .
B2000000  OK
DEV-MEM @ .
3  OK
>
Encouraging.
 
Datasheet says that device address space starts at 0x01000000
and ends at 0x7FFFFFFF (above is DRAM).  There is a command
line utility to do I/O.  Sending 0x01000000 to 0x03022000 turns on
blue LED, sending 0x0 truns it off.  AFAICS in lina corresponding
address is B2022000.  More generally, there are four GPIO devices
(ports).  Port 0 is at 0x03020000, port 1 at 0x03021000, port 2 at
0x03022000, port 3 at 0x03023000.  Device access should be done in
32-bit units.
 
This suggest that you can do the same from lina using virtual
addresses B302x000 . That is vma-io + 0x0100,0000 (device start) + 2x000.
You probably have to initialize the ports to output in some way
for this to work.
 
I tried first things like above and got segfaults.  AFAICS lina B2000000
corresponds to 0x3000000 in device space, so 0x03022000 corresponds to
B2022000.  It seems that lina did not map block between 0x1000000
and 0x3000000, in this block that are 'ap_mailbox' and 'ap_system_ctrl',
it is probably not wise to mess with them from user space.
 
All io must be accessed with 32 bit. lina provides L! L@ for
this. (My conventions is B-W-L-Q ).
 
1000000 B2022000 L!
 OK
0 B2022000 L!
 OK
 
blinks the LED.  I tried and 64-bit access works too, but it reads
or writes also the second register, so L! and L@ are simpler to use.

Milkv Duos have 5 GPIO ports, formally 32-bit but many lines are
not connected to outputs.  One port in RTC block and has
base address 0x05021000, the other ports are at 0x03020000 + n*0x1000
where n is port number.  Output register is at offset 0, at offset
4 is direction register (setting bit to 1 means that line is an
output).  At offset 0x50 is input register.  Other registers
deal with interrupts.

ATM I have the following:

HEX
: LBIS DUP L@ ROT OR SWAP L! ;
: LBIC DUP L@ ROT INVERT AND SWAP L! ;
: gpio-base DUP 4 = IF DROP 2001000 ELSE 1000 * THEN VMA-IO @ + 20000 + ;
: bit-data 20 /MOD SWAP 1 SWAP LSHIFT SWAP gpio-base ;
: gpio-on bit-data LBIS ;
: gpio-off bit-data LBIC ;

which outputs bits to data register.  To get actual output one
need to set direction register and associate PIN with GPIO function.
There is something more, I tried to hijack Ethernet pins bit I
got no output.  Theoretically pins were associated with GPIO
function and lines were set to output, writes changed data
register, but voltage on the pin did not change.  OTOH, by
changing UART0 TX pin to GPIO is got output, so there is
something special about Ethernet.

BTW: Chip datasheet talks about ports and pin numbers within
ports, Milkv Duo picture uses pin numbers but there is mixup
with ports.  There is command line outility to deal with pins,
it uses different numbering similar to numbering on the board
but not the same.  Linux uses still different ping numbering.
Above I use pin number withing port + 32*port number where
ports are numbered from 0.

--
                              Waldek Hebisch

Date Sujet#  Auteur
24 Sep 24 * 1 euro Olimex RISC-V mini-PC: this needs Forth ;)35Paul Rubin
25 Sep 24 +* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)12dxf
25 Sep 24 i+* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)10Paul Rubin
25 Sep 24 ii`* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)9dxf
25 Sep 24 ii `* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)8Paul Rubin
29 Sep 24 ii  +- Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)1Waldek Hebisch
29 Sep 24 ii  `* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)6LIT
29 Sep 24 ii   `* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)5dxf
29 Sep 24 ii    `* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)4LIT
30 Sep 24 ii     `* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)3dxf
30 Sep 24 ii      `* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)2LIT
30 Sep 24 ii       `- Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)1dxf
28 Sep 24 i`- Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)1LIT
25 Sep 24 +- Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)1David De La Harpe Golden
29 Sep 24 +- Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)1Waldek Hebisch
29 Sep 24 `* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)20LIT
29 Sep 24  `* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)19Paul Rubin
29 Sep 24   `* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)18LIT
29 Sep 24    `* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)17Paul Rubin
17 Oct 24     `* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)16Waldek Hebisch
17 Oct 24      `* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)15LIT
18 Oct 24       `* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)14Waldek Hebisch
18 Oct 24        `* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)13albert
18 Oct 24         `* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)12Waldek Hebisch
19 Oct 24          `* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)11albert
21 Oct 24           `* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)10Waldek Hebisch
21 Oct 24            `* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)9Waldek Hebisch
21 Oct 24             +* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)2albert
23 Oct 24             i`- Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)1Waldek Hebisch
26 Oct 24             `* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)6Waldek Hebisch
26 Oct 24              +* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)3albert
26 Oct 24              i`* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)2Waldek Hebisch
27 Oct 24              i `- Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)1albert
26 Oct 24              `* Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)2albert
26 Oct 24               `- Re: 1 euro Olimex RISC-V mini-PC: this needs Forth ;)1Waldek Hebisch

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal