Update programming on a PIC microcontroller without other external hardware? - usb

I'm having a friend that is an electronics engineer plan and build some PCBs for myself and several friends, for use in an automotive environment. One major goal of this project is to allow the PIC microcontrollers to have the programming updated, without the use of additional external hardware, such as a PICkit or anything along those lines. I would love for us to be able to simply connect the PCB to a laptop or desktop via USB, and simply write updated programming to the controller, just like how an Arduino works.
We are currently looking at a PIC24F08KM204 for the project. Does anyone know how my goal can be accomplished, if it is possible? I don't mind adding some more components to the PCBs, at a reasonable cost, to avoid the need of an external piece of third-party hardware to update the controller as we tweak settings. Is there perhaps another controller line I should be looking at that offers this ability?
I'm not very familiar with a lot of the terms used in this environment, so if anyone that is willing to help wouldn't mind making their response dummy-proof I'd really appreciate it :) :)
Thank you!

What you need to implement is called a bootloader. For PIC24, start here -> http://www.microchip.com/SWLibraryWeb/product.aspx?product=Microchip%20Easy%20Bootloader . If you don't need USB for anything else, use serial port plus USB-to-serial converter chip.

Related

Interfacing Netlogo with external agents

Can someone guide me as googling does not send me to the right places.
I want to adapt netlogo to include players real or simulated with other technologies. I need to interface the netlogo core (running an established game) and have the moves and choices determined by the external entities, which may be human or automania.
In searching for the API to allow this, I can find is the controlling API which is seems to be for running NetLogo muitiple runs of a model and not what I want.
And please before you close this again suggest how I can make this more focused as the problem is finding the starting point....
Can anyone assist.
Regards
Robert
There are two main ways to interface between NetLogo and the "outside world":
The extensions API.
The controlling API.
Which one to use depends on what you're trying to achieve.
You say that you:
need to interface the netlogo core (running an established game) and have the moves and choices determined by the external entities, which may be human or automania.
That, to me, sounds very much like a job for the extensions API, which is what has been suggested to you on the netlogo-devel group. Extensions allow to add new "primitives" to NetLogo, and those primitives can be written in any language that runs on the JVM (Java, Scala, Clojure, etc.)
So if you have a game written in NetLogo and a bot written in some other language that the JVM can interface with (possibly by using the JNI), you could write a new NetLogo extension command that calls out to the bot (e.g., something like bot:play game-state). A game written in NetLogo could then use that command to let the bot play its turn.
If that is indeed what you want to do, then Jeremy has already given you a good starting point in his netlogo-devel answer, and there is not much we can add to this until you have more specific questions.
You also said, however, that you looked at using the controlling API, so maybe what you had in mind is to have a game written in some other language, and use a NetLogo model to generate the behaviour of a particular player in that game. The controlling API allows you to do that. (It's not just for running a model multiple times!) If you look at the examples in the controlling guide, you'll see that you can use the API to send commands to a NetLogo model and to report the results back to your external program. The only constraint is that this external program needs to be able to talk to the JVM.
If you don't think this answers you question, please try to give us a concrete example of a precise thing that you want to do but do not think can be achieve in one of these two ways. We might be able to help you better than.

Using a virtual machine inside of a game?

I am in the design stage of making a 3d "robot programming" game. Inspired by games such as Colobot, Robot Odyssey, Cholo, etc.
I want every robot in the game to have it's own isolated environment/operating system/virtual machine just as they would in real life. Each environment should be sandboxed so that it is local to the robot in terms of how it interacts with the rest of the game.
Originally I was going to implement the HACK VM as described in the book "Elements of Computing Systems", but then got curious as to whether there is a better solution in terms of performance for this style of game.
So my question is: Is there a virtual machine architecture already existing that would serve my purpose well?
P.s. The language and game engine to be used has not been decided yet, but will probably be either C# or smalltalk.
Hmm.. using a separate image per robot is a bit of overkill IMO.
I don't know the requirements of your project, but why just don't run all robots in same image using own Process?
(You must know that smalltalk supports green threading model).
About HydraVM: originally it was a proof of concept project. Surprisingly it is worked well and quite stable.
But for further development you need a projects which really require such architecture.
And frankly, smalltalk language-level infrastracture was not ready for it at that moment (i wouldn't say that it is ready today ;)
Because to leverage that, you need a better tools like remote debugging, remote browsing, remote image management etc etc.
I am really surprised to hear that you were able to run 11 images in parallel. That's awesome. Since i never tried to run more than 2 :)
The problem with such many images, that you need a different memory management system. And one which used in Hydra is inherited from Squeak VM and are not really fits with such design.

Hardware Serial Number Discussion. Licence protection

I am working on some application wich will get HDD serial number and then i will use that HDD serial number for licence (cd-key) registration with product. Now the problems wich i can come to:
User have 2 HDD's and once my application gets its serial from first HDD it will register with it so what if user later changes order of HDD's? if the seccond HDD becomes a Master and the first one becomes slave? could be solved with getting both and combine them togather but what if later he removes one then? :D
What if user's HDD dies and he buys new one? Is still same pc only another HDD. So the licence wont be walid anymore just because is another HDD.
Is it possible to fake it? Example i am using VB.net 2010 and application is working on framework(.net) so there is some "dll" wich is responsible to get the serial of HDD so would be possible to replace this "dll" (crack it) so it returns some hardcoded serial of hdd?!?
Could be possible to get processor serial? that would be much batter but could it be done? and does the processor have serial, i mean probably have but is it possible to get it? and same question as abowe could it be faked through changing "dll" or something?
anny other suggestions or experiances?
I seen there are more questions like this but couldnt find some answers so now i ask here!
------ EDITED/ADDED: -------
As talked below i forgot all .net can be decompiled in few secconds! so...
Making own installer. Why?
if i make an installer in wich you enter serial and only if serial is ok to use then install software so what it does? it extracts my software to your computer and again you have ".net" exe wich you can easely decompile and make a crack for it so where is point in making installation with serial!? or if my software is "protected" with some obfuscator so then installation with serial is unneded here i could then simply include serial registration in my software and using some booleans store registered=1||0
i got email from one person here, btw. duno where you got my mail :) and he says some smart things and why some of you people dont respond to my question and this discussion and what he says is this: "scared that others will see my code and how bad it is." so then people just dont want to spent time on this. well thats not problem i know my code is big "minestrone", big mess much words(variables) some on english some on croatian so on well my software is working thats important and i know i suc* we all suc* everyone knows something(more or batter) that the other one. anyway, thats not problem, problem is that i dont want that the software is open source lets say my software is "photoshop" and now someone downloads click there and there and have the whole code and can easely copy paste change few things and no problem he made good application :)
custom compiler? anyone have experiances? would it be ok for some time? :)
what other solution or language would be good to use in future to avoid this "open source" .net! i been looking around so for vb.net, c#, c++ is all based on .net so is all same. vb6 wich i love again same thing. they all can easely be decompiled! what language could not be so easy to decompile? should i switch to assembler? :D i joke, i hope! :p
maybe i just too much stressed up, much work! duno you decide :)
PLEASE READ MY QUESTION AND PLEASE DONT ANSWER ME SOMETHING LIKE "PIRACY CANOT BE STOPED BLA BLA" AND THINGS LIKE THAT. THAT WASNT MY QUESTION! THANK YOU!
Sorry on bold big latters but some people read just title and then answer stupidities! If you want talk about it then read question and write otherwise dont post some stupidities please
Let me first answer your questions:
If the order of the HDDs changes, your application could still find that serial number within the system. However, in either case I would resort to a scheme where I use the device of the system partition or so.
If the HDD dies, the user will be in trouble. There is no good solution to that as long as you insist on your source for the uniqueness of the user's system: i.e. the HDD serial.
It's absolutely possible, yes. At different levels, though. A cracker would always choose the simplest method.
Yes. I'm afraid that will only work with unmanaged code, though. See Wikipedia. And yes, this could be circumvented again by DLL placement (see my comment on the question).
Now let me give you an advice that worked fine for me. Use the SID of the machine account (not to be confused with SYSTEM, which has a well-known SID). And before you counter with NewSid (which, by the way has been retired by MS), this is much more effort to change, especially in domain environments and can have very nasty and unforeseen effects. Therefore if you want to tie your application to a Windows installation, the SID will be sufficient. The SID has the same advantages as a UUID you could create, but it's not as easy to manipulate as a UUID that you store in the registry or a file.
Oh, and before I forget to mention it. Yes, even using the SID can be "cracked" in various ways. But it balances convenience for the user with your demand for security.
Yes, you have to be aware of that. You'll need several fall back methods to take care of this
You have to be aware of that as well.
Everything is fakeable with some energy behind it. However, why fake such an id if you simply can manipulate the program itself? All .net code can be disassembled and manipulated
I think this is possible as well, but would have the same problem behind it.
Other suggestion:
Just because there is piracy, don't make the experience bad for your customer. Use something that is reuseable (like a serial number or keyfile), invest in a good obfuscator to make it harder for somebody to inspect your code, but beyond all: Make your application stand out so people buy it. And even though you didn't ask for it, I have to say it - you can't stop piracy by enforcing orwellian-like surveillance of your program. This will drive customers away as it is a pain in the *ss to work with your application. With a serial or keyfile you still have some sort of protection, the customer likes it because it is easy to use, he doesn't have to call you/write a support ticket if his computer fails or the stars align unfavourable. Pirates will break it eventually, but your customer is happy, and that is what counts.
Anything you rely on which is in userland can and will be spoofed if it is worthwhile to the end user/attacker. So locking the licence to an HDD serial number will not put of attackers, but it will seriously upset your customers.
The same goes for processor serial numbers - it is too easy to pop some code inline to change what your application will read.
Your only reasonable bet will be dongles - ie specific hardware, or a way to get them to register and run with an online connection, so you can validate them using elements you control (although in saying that, if your app is high enough value, expect the dongle to be hacked/replicated too!)
Your biggest problem may be overdoing the security - if you get it wrong in any way you will alienate your customer base.
People regularly upgrade failed hard drives, or those which are too small, as well as most other components in their computers. If you stop them using your product, even for a couple of days, they are likely to look elsewhere!
You can do what you are suggesting, but there are issues. What you are suggesting is called "machine binding" in the licensing world. There are commercial tools that do this for you (disclaimer: I work for one such provider Wibu-Systems). What YOU are proposing has some pros and cons:
Pros: requires no separate hardware (dongle), you can roll your own, easy solution to implement at a basic level.
Cons: can be cracked in a matter of minutes, will create problems for users when they change the HW config or move the app to a new PC, rolling your own will introduce the oppty for new bugs in an area you apparently have no prior experience with.
Why not use a commercial solution? Would you write your own setup program, too? How about your own compiler, linker, and debugger?

Searching for a drive bay LED/LCD with buttons hardware and API

My colleagues and I have got an interesting little prototype hardware/software project that would follow these loose requirements/specs/implementation details:
Hardware:
Take simple user input from a couple of buttons, maybe a dial
Give some textual output to the user, a 3-line LED would suffice but fancier is OK
Powerful x86 CPU required
Software
Windows-based OS
Simple, easy to program to API for LED/LCD pannel input & output. Preferable Java, or another high-level language.
No monitor connected in most use cases
It looks to me like my project is exactly what the HTPC folks are doing, but after an hour of Googling and researching, I can't seem to find any specifics on programming the hardware for HTPC cases from Silverstone, et al.
Can someone point me in the right direction?
LCDSmartie may be a source for your required library.
http://lcdsmartie.sourceforge.net/
You may need to use it as a basis for some hacking.

Do you think you need some simple tutorials on Microcontroller programming?

This is not 100% programming related. But I think this is somewhat useful because it is addressing a minority in the SO community.
Microcontroller programming is one of the interesting areas in programming. I saw some topic here requesting the Resources for starting / learning / discussing about PICs.
Example topic
Since I have plenty of knowledge and experiences in this area I am thinking of publishing some resources that helps a novice to learn them from the basics. It will be not just a theoretical publication and will be based on example projects. I hope to start this over a new blog + forum so the users can dynamically interact with each other. I came in to this decision because I found very small amount of Sites that a novice can start learning and work collaboratively.
What do you guys think about this? Have you ever experienced such difficulty? Do you think you can get some use of that? What are the things you like to see on the site?
I would be thankful If you are not going to close this as NPR. I just want to do some service to other microcontroller lovers :)
There are already a few such tutorials on the net (e.g. this one from SparkFun), another one might be a valuable addition, but only if it is better or different in some way.
What will you offer that is a real improvement?
Some suggestions:
Don't assume I have windows
Have some side discussion of difference between various MCU and/or supporting electronics. Discuss some of the trade offs
You'll need a pretty general tutorial to suck people in, but the real value added might be in a specialized focus after the start
Build up to something useful and/or geeky cool
A unit on component integration (i.e. I can buy a Polar style heart rate receiver, and a MCU and a USB interface. How do I get them talking to each other so I can build an exercise data logger?)
What every you do, I'm looking forward to it (just learning embedded stuff in my spare time...).
There are the excellent tutorials at www.mikrocontroller.net, but they are in German.
If you could create something similar for an English speaking community, that would be great.
Yes! The more resources out there for helping with embedded software (microcontroller programming) the better.
It can be quite daunting to start with, especially if you've only written software for PCs or similar in the past. There are lot more constraints (e.g. on RAM and code space), and a whole load of things you need to know that don't apply to non-embedded software.
As others have mentioned here, there a number of websites that cover different aspects of this; some others are OnARM, for ARM processors, the related STM32 Circle, and Jack Ganssle's articles on his website and on Embedded.com.
Though embedded systems are an enormous market (just think how many such devices there are in your house, or in your car), my impression is that there is a lot less coverage of the subject on the web - and on Stack Overflow - than for non-embedded.
So, I look forward to seeing the fruits of your labour!
Something else that's worth to take into account when targeting beginners, is to directly provide pointers to useful resources, such as suitable simulators/emulators, or even addresses/webpages where you can easily order a starter kit or even free samples of some chips.
For example, most semiconductor manufacturers provide free samples of their products, e.g. see microchip.com or atmel.com.
Ideally, an introductory course would be based on working with such a hardware simulator or emulator in the beginning, so that the project and all relevant experience may directly map onto a real device once the beginner is interested in moving his work onto a real chip, providing pointers to freely available resources, or very affordable starter kits can be very useful.
This would ensure that beginners can get started as easily and cheaply as possible.
Maybe for the different ARM7 and CortexM3...?
Here everyone asumes there is a lot of information, but it is spread all over the net and without any red line what so ever...
But if you take AVR there is quite a lot of stuff over at http://www.avrfreaks.net, and I guess that PIC has quite a lot as well.
I have written many such examples myself but they are scattered and not organised and probably rarely read (one time the folks at avrfreaks borrowed something). StackOverflow might curb this but SO could in theory be used. Ask a question about boot code for an arm whatsit, then answer your own question with example code and text on how and why it works. The SO tags would be nice in that you could do a search on "boot" "arm" "embedded" and then one on "boot" "avr" "embedded", etc and get similar example programs for different platforms.
Personally I would go more in the direction of creating an example archive of complete programs for specific microcontroller versions (in typical uses), instead of making yet another "general" tutorial. E.g. one of microcontroller x/y that enables a serial port, one that configures a few digital outputs (setting TRIS and friends), how to set up common frequency/oscillator options etc.
When I started with PIC, (very short PIC16, then PIC18 then 24F and now dspic), one of the main problems is that all the examples are either only fragments or describing very general principles.
A tutorial is no good, if it takes more skills to get the examples actually working than the tutorial teaches.
I usually couldn't find one single complete program for exactly my controller, or even for the slightly wider group (that only vary in number of pins and memory/flash).
The initial program was always the problem, but sometimes later I had the same problem (initializing a certain peripheral) all over again (e.g. the encoder) It is specially frustrating if is the first run of a new micro controller line, and you might not be 100% sure of your hardware.
Unfortunately that takes some coordination, from a forum, an user group or so, since nobody has all devices, and all variants to wire them up (e.g. different oscillator options).