vblang icon indicating copy to clipboard operation
vblang copied to clipboard

Proposal: Lightweight VB runtime for IoT

Open rrvenki opened this issue 6 years ago • 31 comments

Lately we are programming more on IoT devices and it is most of the time C code (Arduino code repository) or Lua scripting. ESP32, ESP-EYE has inbuilt Vision and Vernacular functionality which can be utilized by our programs. It appears that the Memory and OpCodes are limitations in ESP chips to have VB runtimes loaded.

Idea:

  1. Create a ".NET IoT" as a subset of ".NET Core" which can be loaded into chips like ESP. The ".NET IoT" to use "Reduced RISC" (Reduced-Reduced Instruction Set Computing) to target sub $8 chips like ESP which has dual core CPU, Built-In Memory, Camera, Mic and Buzzer speaker.
  2. Support LinkPoke in ".NET IoT" for communication (#383).
  3. Make these chips directly participate in AD authentication via ".NET IoT".
  4. Allow VB.NET programming to target ESP or similar IoT platform.
  5. Chipmakers to increase current 4MB memory on chip or use CrossBar technology within existing cross section.

Help: @KathleenDollard please guide us creating ".NET IoT".

rrvenki avatar May 01 '19 07:05 rrvenki

I see two approaches to this. One, as you say, have a new .NET Runtime that targets IoT devices and add support for the VB runtime to optionally be utilized as part of this (which would, of course, most likely be an afterthought) given that such a framework would most likely be C# first (not trying to knock this, I'm just a realist). The second approach would be to allow a third-party to build first-rate products around targeting IoT devices where we could leverage our knowledge and skills as VB.NET devs to enter into that arena in a way that feels non-forced (natural). As it turns out, there is already a project out there that is doing a pretty good job on this front; however, they probably need some help with regards to input. For example, they have an ifdef compiler directives; however, these are not the same as what is in VB (missing the Then). It could easily be added as an optional (recommended) keyword. We could also assist them with a "runtime" that eases the VB.NET dev to build anything that the Arduino platform currently can target. You should check out B4R (you can find the link at https://gotbasic.com/AVR.html). It isn't a perfect solution; however, it certainly looks like a great start and definitely has potential to be a strong solution for this problem space. At the end of the day, it still has to fit in the confined space that these microcontrollers have and Arduino has kind of led the way in popularizing the space for us normal peeps. If we could get some people in the community to encourage better symbiosis with VB.NET; that could be very interesting. As you can see on the link I've provided... B4R isn't the only game in town either (if you know of any others, please let me know so I can update the list).

DualBrain avatar May 04 '19 02:05 DualBrain

In other words, I'd like to see a model between VB.NET and B4R (or something similar) where we could share more code between the two platforms... in the end, I think this will be the best that it could be (regardless of whether or not Microsoft was to make a .NET IoT specific CLR for microcontrollers) since the variety of the devices is so great and the memory space is extremely limiting. In other words, I don't think that .NET is the right answer here; but having something where we can leverage our skills... that's a very different story.

DualBrain avatar May 04 '19 02:05 DualBrain

Sorry for delayed reply (due to medical reasons). I wish to start a project in Git by taking existing VB compiler code and stripping off which are not required or does not run on NodeMCU 1.0 (or ESP12-32). For the unsupported opcodes, create methods/ways to achieve them. I foresee memory could be the challenge which is not a showstopper. A NodeMCU can be added with a 4-8GB chip or SD card to address memory issues. A open source hardware platform like this could be a great help in the process. By doing so if we can get 50-60% of the existing compiler features working on a ESP8266 (NodeMCU) chip, it will help program a very large set of basic functionalities which these chips are capable of. That in commercial terms would translate into several billion dollars. With that in mind i'm trying to find a right place to put my leg down and start this and seek technical help from like minded people from this forum.

rrvenki avatar Jun 18 '19 08:06 rrvenki

I think a lot of this work might have already been done... does anyone remember the Netduino (https://www.wildernesslabs.co/Netduino)? Let's not forget about "SPOT". By the way, anyone looking for some cool retro hardware - I think I even have a couple of these watches (https://en.wikipedia.org/wiki/Smart_Personal_Objects_Technology) somewhere (new/unopened). ;-)

In all seriousness, you might want to investigate these projects as a good starting point. I remember many years ago a lot of work that was done in order to allow the VB compiler (pre-Roslyn) to be able to target more "limited" targets - don't remember if they were specific to these IoT (before IoT was even the label being used) - but there was work done to "trim" the output so that the compiler would work in these sorts of targets (including the Xbox 360).

Might also want to look at: https://en.wikipedia.org/wiki/.NET_Micro_Framework

Don't get me wrong, I am definitely interested in IoT... I just brought up what I'm aware of as projects that already exist today that allow me to use my BASIC skills to target these devices (today). With that said, I do think that most of the effort around doing this for IoT will fall upon "the community" as this isn't an area that I see Microsoft investing in heavily... so if it is going to happen it's a matter of us (the community) to roll up our sleeves and get to work. At some point there may need to be some involvement from the .NET Core / Roslyn teams to assist where there may be a blocking issue regarding getting things to work. However, I also suspect that most of those issue are probably resolved given the previous projects I mention. So if you (or anyone else) decides to move forward with this... please keep us in the loop on the progress.

DualBrain avatar Jun 20 '19 21:06 DualBrain

  • Might also want to look at: https://en.wikipedia.org/wiki/.NET_Micro_Framework https://en.wikipedia.org/wiki/.NET_Micro_Framework Yes, and I remember MS let their partners who invested in the platform down to their fate, one name for all GHI electronics.

Padanian avatar Jun 20 '19 21:06 Padanian

@DualBrain @Padanian Thanks for sharing details on Netduino and .NET Microframework.

  1. The competition from Open Source Hardware platform products like Raspberry, Banana etc. could have been a larger challenge. Adoption of these devices with non Microsoft OSs and large scale investment from Chinese firms are other potential reasons for it not being used.
  2. Appears this Netduino is on .NET Microframework is due to the limitation of hardware of the respective time.
  3. It needs a street smart CEO to strike deals with right partnerships to make it real big as of now.

For example grow the existing hardware continuously and look for partnerships with companies like CrossBar who bring very high capacity memory in same cross-section. Work out other CPU options (Intel and others) and include GPU and if possible HPU. Target to remove the difference between volatile and non volatile memory (RAM-ROM) and this will become DISRUPTIVE. Use full or Core .NET versions.

Most importantly give example code in VB.NET than C#.

The full project does not require big investment. As far as the price is competitive with Raspberries (at least 1$ less than competitors), this is destined to become next sensation. I would request not to abandon this project. Please let me know how we can participate in its growth - both Software and Hardware.

rrvenki avatar Jun 21 '19 04:06 rrvenki

Came through NanoFramework in github. This is promising .NET for Microcontrollers. Again... Its only C#.

I could not figure out the nanoFramework code in github. How to get nanaFramework to support VB.NET? Any heads up? If it requires some development, i'm ready to contribute on coding and samples building.

I do a lot of code - nearly 40-50% in Arduino using C to work in Microcontrollers like ESP32. I can visualize if C# can be used now with nanoFramework and VS2019, why not VB.NET? Where to start?

@KathleenDollard @josesimoes @networkfusion @DualBrain @Padanian @tverweij @paul1956

rrvenki avatar Feb 11 '20 12:02 rrvenki

In principle there shoudn't be any problem in writing vb code referencing the same dll's . Funny enough, "The nanoFramework platform picks up where .NET Micro Framework left off" which is one of many MS dumpster abortions and brought netduino down with it, and that stranded a number of early adopters.

Padanian avatar Feb 11 '20 13:02 Padanian

@rrvenki know that the amount of work required to add support for VB in nanoFramework is not that huge.

The decision for not adding support for VB.NET was conscient and made at the beginning of the project. If there is interest from the community and dev hours to pour on the task we can show the way! 😄

josesimoes avatar Feb 13 '20 03:02 josesimoes

@josesimoes, I would suggest you show the way and there will be following. While C and VBScript are supported in Arduino IDE platform how long would it take to support VB.NET? We do a lot of C coding for ESP32. Post COVID19 lockdown and China related trade fiasco we expect availability of ESP32s at current price would be a big ask. Already the ESP32 prices in India has got large now. However, Its still high time to create a Framework & VB Compiler which can run on minimum ESP32. Its already dual core and runs LUA system. A thought -> Microsoft already created Windows Nano Server for container purposes with low footprint. Can a similar Win10 be burnt into CMOS which can be easily shipped with ESP32? We may even replace LUA here if required (ESP32 is already an open source hardware. Not just available in India though). CMOS based OS are already available in Banana Pie microcontrollers for instance.

rrvenki avatar Apr 29 '20 12:04 rrvenki

@rrvenki this is something that would require the community involvement. If there are people interested please mention it here so we can devise a plan. Tasks required:

  • [ ] Adding the class libraries.
  • [ ] Updating the build system to support these.
  • [ ] Updating the VS extension to support VB.NET projects.
  • [ ] Tweak the execution engine to support VB.NET specifis.

If there are people willing to tackle the 1st one, we can deal with the other two internally.

josesimoes avatar May 01 '20 14:05 josesimoes

@josesimoes What class libraries would be needed?

DualBrain avatar May 01 '20 14:05 DualBrain

You'll forgive my poor knowledge of VB.NET... 😁 I was referring to the VB.NET runtime (pretty much the equivalent of mscorlib in C#).

Then we have the rest: GPIO, ADC, SPI, I2C, PWM, networking, etc... we have already a bunch of them in C#.

josesimoes avatar May 01 '20 15:05 josesimoes

It is my guess that all that would be needed is the work that was done initially in .NET Core 2.0 called VB.Core; I wonder if that could be leveraged here. It provides the bare minimum to get VB working... it leaves out a lot of the fluff/extras/niceness that is VB, but for the purposes of trying to target something like an ESP32 I suspect that something has to be given up. ;-)

(Actually, I think the VB.Core stuff is pre-.NET Core... probably from the days of getting VB to work on Xbox 360.)

DualBrain avatar May 01 '20 15:05 DualBrain

Actually that's easier than that: we have the VB runtime from .NETMF.

It's probably missing some of the new stuff we've been adding to the C# mscorlib but, nevertheless, functional.

josesimoes avatar May 01 '20 15:05 josesimoes

It's probably missing some of the new stuff we've been adding to the C# mscorlib but, nevertheless, functional.

Are you referring to a custom mscorlib? If so, where could I find that (assuming it's somewhere here on GitHub)?

Also, functional would be a great starting point. ;-)

DualBrain avatar May 01 '20 15:05 DualBrain

Github.com/nanoframework

networkfusion avatar May 01 '20 16:05 networkfusion

I watched the rise and fall of netmf with aw. I'm subscribing the thread and will follow the development. If I can be of any help, reach out.

Padanian avatar May 01 '20 16:05 Padanian

@Padanian I'm (was) on that wagon too. 😉

A handful of devs took the matter on their hands and nanoFramework happened. Take a look what is there. I'm sure you'll like it.

BTW, the project can use all the talent and contributions that people are willing to throw at it. So, by all means, join the party!

josesimoes avatar May 01 '20 17:05 josesimoes

I like it, but I'm overwhelmed by a patchwork of 63 repositories and 16 projects

Padanian avatar May 01 '20 17:05 Padanian

I agree with @DualBrain, it seems like VB on Core is what you want, with Core 3.1 you can package a minimum runtime with only the things you need/use and the existing tooling strip out what you don't use. @Padanian what 63 repositories and 16 projects? Most of my VB applications don't even depend much on VB Runtime, I use Core functions and the VB runtime is now a very thin layer over Core. I think Microsoft plans to expose all the hidden VB stuff by Core 6 so for experienced developers VB is as ugly as C# but for most VB Developers the stuff is just hidden in a source file under My Project. If you look at WinForms/Core repos you will see all the VB hidden stuff.

paul1956 avatar May 02 '20 00:05 paul1956

@paul1956 VB on Core can't be used for this purpose. It has to be a specific VB runtime.

We are talking about running .NET on microcontrollers with ~5120k/1M of flash storage and ~64/512k of RAM. Quite distant from the most lousy PC that you can find able to run Core 3.1. 😉

About the repo and project count above: that's the stats for the nanoFramework GitHub organization.

josesimoes avatar May 02 '20 11:05 josesimoes

@rrvenki this is something that would require the community involvement. If there are people interested please mention it here so we can devise a plan. Tasks required:

  • [x] Adding the class libraries.
  • [x] Updating the build system to support these.
  • [x] Updating the VS extension to support VB.NET projects.
  • [x] Tweak the execution engine to support VB.NET specifics.

If there are people willing to tackle the 1st one, we can deal with the other two internally.

@josesimoes, Including me we are three guys full time coding on IoT and few other .NET Core projects. Once we are clear on the requirements of the class libraries we can churn it out. Equally we can work on other items also. I'd be also interested to migrate the VBScript programming in Arduino sketch to VB.NET.

rrvenki avatar Jul 10 '20 20:07 rrvenki

Yeah its long time now and surviving Covid19 loosing family members is even more tough. @josesimoes, if you still see this thread pls give heads up or direct us to the C# github for "Adding the class libraries" stuff. We can get our hands dirty.

rrvenki avatar Jun 15 '22 06:06 rrvenki

@rrvenki glad to hear from you again! 😃 And, of course, that you're willing to help making this happen.

First step would be to get a build on the equivalent for the runtime. Please check here from the original .NETMF repository.

FYI: I have never attempted to follow those instructions so I'm not sure that that even works. After that step is accomplished we should follow up to move forward.

josesimoes avatar Jun 15 '22 15:06 josesimoes

Hi @josesimoes, I've started work on the code.

  1. We can communicate in a more private channel if possible.
  2. After hand coding SpotVBasic.vbproj under "\netmf-interpreter\Framework\Subset_of_VisualBasic", i got it accepted in VS2022. Then i pulled basic required nugets.
  3. Now i get 126 Errors. Of which most of it is "Error BC31424 Type 'System.Attribute' in assembly 'SpotVBasic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' has been forwarded to assembly 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Either a reference to 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is missing from your project or the type 'System.Attribute' is missing from assembly 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'." This may be because i'm targetting .NET 7 preview version and not pointing the right Sytem.Runtime.
  4. Also let me know how to get the dependencies from other folders incorporated in this project or at least the list of them.
  5. Let me know if i'm on right track.

rrvenki avatar Jun 17 '22 11:06 rrvenki

@rrvenki I would say, from the above, that you are on the right path. Suggests that we use Discord to communicate. Please join NET nanoFramework server here https://discordapp.com/invite/gCyBu8T.

josesimoes avatar Jun 17 '22 17:06 josesimoes

@rrvenki @josesimoes if/when you create a specific channel for this (or utilize an existing channel), can you please update here so that others (like me) that want to follow along can do so?

DualBrain avatar Jun 17 '22 18:06 DualBrain

Hi, I created a new project by name MiniBS "rrvenki\MiniBS" in github. Currently its private. Was thinking if its advisable to go ahead with new project or create a branch in "netmf-interpreter" and continue with changes. If @josesimoes can advice on that we can quickly get into next level.

rrvenki avatar Jun 29 '22 07:06 rrvenki

@rrvenki can you please send me an invite for that repo so I can take a look at it?

If this is bound to move forward, agreed that work should be done in the nanoFramework github org.

josesimoes avatar Jun 29 '22 23:06 josesimoes